diff options
author | Colin Cross <ccross@android.com> | 2014-07-22 15:55:08 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2014-07-22 17:47:03 -0700 |
commit | 18fae75350bcd5f19ef90afb533e3fbedfd4c83b (patch) | |
tree | 37391221cefde051b250b645f07b57b83bc42723 /libs/ui | |
parent | 78014f32da6d0ebf52fb34ebb7663863000520a0 (diff) | |
download | frameworks_native-18fae75350bcd5f19ef90afb533e3fbedfd4c83b.zip frameworks_native-18fae75350bcd5f19ef90afb533e3fbedfd4c83b.tar.gz frameworks_native-18fae75350bcd5f19ef90afb533e3fbedfd4c83b.tar.bz2 |
crash if getNativeBuffer() called on NULL GraphicBuffer
If getNativeBuffer() is called on a NULL GraphicBuffer the
static_cast of this from GraphicBuffer* to ANativeWindowBuffer*
will return a small pointer like (ANativeWindowBuffer*)0x10.
This value can propagate past NULL checks until it causes a crash
far away from the original NULL pointer. Crash immediately
instead.
Change-Id: Id614b9eb1484108b3c3c733545309844c4b87532
Diffstat (limited to 'libs/ui')
-rw-r--r-- | libs/ui/GraphicBuffer.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp index e21dc53..9b0bd60 100644 --- a/libs/ui/GraphicBuffer.cpp +++ b/libs/ui/GraphicBuffer.cpp @@ -126,6 +126,7 @@ void GraphicBuffer::dumpAllocationsToSystemLog() ANativeWindowBuffer* GraphicBuffer::getNativeBuffer() const { + LOG_ALWAYS_FATAL_IF(this == NULL, "getNativeBuffer() called on NULL GraphicBuffer"); return static_cast<ANativeWindowBuffer*>( const_cast<GraphicBuffer*>(this)); } |