Merge "libgui: Check slot received from IGBP in Surface" into lmp-dev am: 98e3c06010 am: 970bb51580 am: 78976cea8f am: 2fe15aa6f0 am: cce83f15e5 am: 9a44ee0742 am: 787aa48f41 am: f69675e5c2 am: d65a388e1b am: b829d2abe9 am: 79a34dd24b am: a1b1e635cc am: 0c7f6e142d
am: 29c221a2e5

Change-Id: If5f2a500feb74d2b4f8b87d357ddc0143325a944
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index a6d9e66..ecf27f4 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -513,6 +513,12 @@
         return result;
     }
 
+    if (buf < 0 || buf >= NUM_BUFFER_SLOTS) {
+        ALOGE("dequeueBuffer: IGraphicBufferProducer returned invalid slot number %d", buf);
+        android_errorWriteLog(0x534e4554, "36991414"); // SafetyNet logging
+        return FAILED_TRANSACTION;
+    }
+
     Mutex::Autolock lock(mMutex);
 
     sp<GraphicBuffer>& gbuf(mSlots[buf].buffer);