OSDN Git Service

libs/ui: Fix crash issue because of null pointer access
authorBaldev Sahu <bsahu@codeaurora.org>
Tue, 26 Nov 2013 12:09:43 +0000 (17:39 +0530)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Mon, 3 Feb 2014 14:26:53 +0000 (22:26 +0800)
- handle NULL check is required while flatten GraphicsBuffer

CRs-fixed: 579102

Change-Id: I292b4b25dc1f5320378cc9e4affbad326e1fdaed

libs/ui/GraphicBuffer.cpp

index 0ecd3d9..e69a824 100644 (file)
@@ -231,12 +231,12 @@ status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t&
         native_handle_t const* const h = handle;
         memcpy(fds,     h->data,             h->numFds*sizeof(int));
         memcpy(&buf[8], h->data + h->numFds, h->numInts*sizeof(int));
+        fds += handle->numFds;
+        count -= handle->numFds;
     }
 
     buffer = reinterpret_cast<void*>(static_cast<int*>(buffer) + sizeNeeded);
     size -= sizeNeeded;
-    fds += handle->numFds;
-    count -= handle->numFds;
 
     return NO_ERROR;
 }