Fix invalid iterator in CloseCdm

[ Merge of http://go/ag/5334065 and http://go/wvgerrit/65122 ]

Sessions were not being correctly released when CloseCdm() was called.
Broadcom noticed this issue and proposed the fix.

Bug: 117876077
Test: WV unit/integration tests, GtsMediaTestCases and playback tests
Change-Id: I8800744f2396f0955c76d5f3e187a69fe04330f6
This commit is contained in:
Rahul Frias
2018-10-23 00:12:45 -07:00
parent c0144ac97f
commit d374b17b7c
2 changed files with 57 additions and 3 deletions

View File

@@ -434,9 +434,12 @@ CdmResponseType WvContentDecryptionModule::CloseCdm(
return UNKNOWN_ERROR;
}
// Remove any sessions that point to this engine.
for (auto session_it : cdm_by_session_id_) {
if (session_it.second == it->second.cdm_engine.get()) {
cdm_by_session_id_.erase(session_it.first);
for (auto session_it = cdm_by_session_id_.begin();
session_it != cdm_by_session_id_.end();) {
if (session_it->second == it->second.cdm_engine.get()) {
session_it = cdm_by_session_id_.erase(session_it);
} else {
++session_it;
}
}
cdms_.erase(it);