gralloc: fix nullptr dereference
This happens only for host side tests where we free and unregister
in the same process. Post-Treble Android usually expects not to do this.
However, this CL should not affect behavior of guests either pre or post
Treble.
Change-Id: I4fac91c6d4c7031ac19e7c75233451663e3d31c4
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index 0379d32..e3bf5d6 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -802,7 +802,9 @@
int32_t openCount = 1;
int32_t* openCountPtr = &openCount;
- if (isHidlGralloc) { openCountPtr = getOpenCountPtr(cb); }
+ if (isHidlGralloc && cb->ashmemBase) {
+ openCountPtr = getOpenCountPtr(cb);
+ }
if (*openCountPtr > 0) {
DEFINE_AND_VALIDATE_HOST_CONNECTION;