Fix integer sanitizer in clearkey.

Calculating index sometimes causes an unsigned integer overflow. This
throws a runtime error on integer sanitized builds.

 runtime error: unsigned integer overflow: 0 - 1 cannot be represented
 in type 'unsigned int'

Since this gets implicitly converted to ssize_t anyhow, make the
conversion explicit before decrementing to avoid the overflow.

Bug: 30969751
Test: Compiles.
Change-Id: Ibd39c1ba0dc64673743672ffc70c22c09f8e828a
Merged-In: Ibd39c1ba0dc64673743672ffc70c22c09f8e828a
gugelfrei
Ivan Lozano 7 years ago
parent 240201e27b
commit f1151c3ef7

@ -95,7 +95,7 @@ void ClearKeySessionLibrary::destroySession(const CasSessionId& sessionId) {
void ClearKeySessionLibrary::destroyPlugin(CasPlugin *plugin) {
Mutex::Autolock lock(mSessionsLock);
for (ssize_t index = mIDToSessionMap.size() - 1; index >= 0; index--) {
for (ssize_t index = (ssize_t)mIDToSessionMap.size() - 1; index >= 0; index--) {
sp<ClearKeyCasSession> session = mIDToSessionMap.valueAt(index);
if (session->getPlugin() == plugin) {
mIDToSessionMap.removeItemsAt(index);

Loading…
Cancel
Save