Merge "libgui: Check slot received from IGBP in Surface" into lmp-dev am: 98e3c06010 am: 970bb51580
am: 78976cea8f

Change-Id: I30e6a29474b6cf86f97961f527301837b35c8a36
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp
index 4b76f98..22aa4ec 100644
--- a/libs/gui/Surface.cpp
+++ b/libs/gui/Surface.cpp
@@ -237,6 +237,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);