From e2d1157381b863a94ccb36a1c6d70cad47e79c1a Mon Sep 17 00:00:00 2001 From: Jun Jiang Date: Tue, 29 Apr 2014 14:15:36 +0800 Subject: [PATCH] fix GraphicBuffer::flatten crash issue when handle is null Change-Id: I0d3727e4366cac355791e52cb7790bf8f3c51527 Signed-off-by: Jun Jiang --- libs/ui/GraphicBuffer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 96a718841..c4e4efa1c 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -235,8 +235,10 @@ status_t GraphicBuffer::flatten(void*& buffer, size_t& size, int*& fds, size_t& buffer = reinterpret_cast(static_cast(buffer) + sizeNeeded); size -= sizeNeeded; - fds += handle->numFds; - count -= handle->numFds; + if (handle) { + fds += handle->numFds; + count -= handle->numFds; + } return NO_ERROR; }