Adding negative slot index check in ComposerResources

Bug: N/A
Test: build, boot
Change-Id: I8ab18ed8f7c322ee995abc534309b51e796276fe
This commit is contained in:
Valerie Hau
2019-03-27 10:06:12 -07:00
parent 17b3a4f60f
commit ef77263b2f

View File

@@ -170,7 +170,7 @@ class ComposerHandleCache {
}
Error lookupCache(uint32_t slot, const native_handle_t** outHandle) {
if (slot < mHandles.size()) {
if (slot >= 0 && slot < mHandles.size()) {
*outHandle = mHandles[slot];
return Error::NONE;
} else {
@@ -180,7 +180,7 @@ class ComposerHandleCache {
Error updateCache(uint32_t slot, const native_handle_t* handle,
const native_handle** outReplacedHandle) {
if (slot < mHandles.size()) {
if (slot >= 0 && slot < mHandles.size()) {
auto& cachedHandle = mHandles[slot];
*outReplacedHandle = cachedHandle;
cachedHandle = handle;