Prevent segfaults when a session is deallocated

[ Merge of http://go/wvgerrit/26201 ]

Race conditions arose when a session was closed while data was
still queued for decryption in MediaCodec buffers. If a session
is closed while data is still queued for decryption, subsequent
decryption requests will be rejected with a CryptoException
ERROR_SESSION_NOT_OPENED.

Test: Verified by wv unit/integration test and
      WvCdmExtendedDurationTest.DecryptionCloseSessionConcurrencyTest

b/36747801

Change-Id: I044d1d6b9fc886a1c353d20b9c6365319aa71e80
This commit is contained in:
Rahul Frias
2017-04-19 17:20:08 -07:00
parent c2969ef0f4
commit f2fccc20cd
2 changed files with 107 additions and 0 deletions

View File

@@ -1286,6 +1286,7 @@ CdmResponseType CdmEngine::Decrypt(const CdmSessionId& session_id,
// else we must be level 1 direct and we don't need to return a buffer.
}
AutoLock lock(session_list_lock_);
CdmSessionMap::iterator session_iter = sessions_.end();
if (session_id.empty()) {
// Loop through the sessions to find the session containing the key_id