From 8faa3262f367f8f10ff310ac3c097b860ba9cc3e Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 4 Dec 2014 18:58:14 -0800 Subject: DO NOT MERGE - audio policy: fix inifinite loop in clearAudioPatches() releaseAudioPatch() does not necessarily remove the audio patch from the list. Scan the list from the top down to avoid adjusting the index. Bug: 18621514. Change-Id: I58787154680f7cb1818509017835b1693d62190f --- services/audiopolicy/AudioPolicyManager.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'services') diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index 536987a..3e1506d 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -2561,13 +2561,10 @@ status_t AudioPolicyManager::setAudioPortConfig(const struct audio_port_config * void AudioPolicyManager::clearAudioPatches(uid_t uid) { - for (ssize_t i = 0; i < (ssize_t)mAudioPatches.size(); i++) { + for (ssize_t i = (ssize_t)mAudioPatches.size() - 1; i >= 0; i--) { sp patchDesc = mAudioPatches.valueAt(i); if (patchDesc->mUid == uid) { - // releaseAudioPatch() removes the patch from mAudioPatches - if (releaseAudioPatch(mAudioPatches.keyAt(i), uid) == NO_ERROR) { - i--; - } + releaseAudioPatch(mAudioPatches.keyAt(i), uid); } } } -- cgit v1.1