diff options
author | Lingyun Zhu <lingyun.zhu@intel.com> | 2012-11-20 19:24:35 +0800 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2013-08-13 11:51:48 -0700 |
commit | 2aff7025482cc40d2ebd45f81cdb318ac1c6f868 (patch) | |
tree | f598dd6c837fb1a52c63ee48de89871b299a9d94 | |
parent | 046b72fc5d93aae3b47b88b9f6683512d01d75d0 (diff) | |
download | native-2aff7025482cc40d2ebd45f81cdb318ac1c6f868.tar.gz |
Graphics:Add error check when create GraphicBuffer
Change-Id: Ib0ca59bf1dfe4ae0266c29c91c1dbe3d02c0904e
Author: Lingyun Zhu <lingyun.zhu@intel.com>
Signed-off-by: Lingyun Zhu <lingyun.zhu@intel.com>
Signed-off-by: Shuo Gao <shuo.gao@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Signed-off-by: Jack Ren <jack.ren@intel.com>
Author-tracking-BZ: 50141
-rw-r--r-- | libs/gui/IGraphicBufferProducer.cpp | 6 | ||||
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp index 63d7628a55..c33543958b 100644 --- a/libs/gui/IGraphicBufferProducer.cpp +++ b/libs/gui/IGraphicBufferProducer.cpp @@ -62,7 +62,11 @@ public: bool nonNull = reply.readInt32(); if (nonNull) { *buf = new GraphicBuffer(); - reply.read(**buf); + result = reply.read(**buf); + if(result != NO_ERROR) { + (*buf).clear(); + return result; + } } result = reply.readInt32(); return result; diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index 580788d0e9..83ae469833 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -281,6 +281,8 @@ status_t GraphicBuffer::unflatten(void const* buffer, size_t size, if (handle != 0) { status_t err = mBufferMapper.registerBuffer(handle); if (err != NO_ERROR) { + width = height = stride = format = usage = 0; + handle = NULL; ALOGE("unflatten: registerBuffer failed: %s (%d)", strerror(-err), err); return err; |