From bd9cbc3b5547e096eca243c3ec7ebe3ee1ab3b89 Mon Sep 17 00:00:00 2001 From: Jamie Gennis Date: Sun, 27 Feb 2011 18:40:09 -0800 Subject: [PATCH] surfaceflinger_client: Don't dereference NULL ptrs. This change adds a null pointer check before dereferencing buffers in a Surface list of known GraphicBuffer objects. If not all the buffers have been dequeued before this list can legitimately contain NULL entries. Change-Id: I0e105b53a3f6f9a5404716b7bf150c793ff648a6 --- libs/surfaceflinger_client/Surface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/surfaceflinger_client/Surface.cpp b/libs/surfaceflinger_client/Surface.cpp index 1e9bd744f..68611d6a3 100644 --- a/libs/surfaceflinger_client/Surface.cpp +++ b/libs/surfaceflinger_client/Surface.cpp @@ -1040,7 +1040,7 @@ int Surface::getBufferIndex(const sp& buffer) const // e.g. if GraphicBuffer is used to wrap an android_native_buffer_t that // was dequeued from an ANativeWindow. for (size_t i = 0; i < mBuffers.size(); i++) { - if (buffer->handle == mBuffers[i]->handle) { + if (mBuffers[i] != 0 && buffer->handle == mBuffers[i]->handle) { idx = mBuffers[i]->getIndex(); break; }