diff options
author | Lingfeng Yang <lfy@google.com> | 2018-10-01 12:00:03 -0700 |
---|---|---|
committer | Lingfeng Yang <lfy@google.com> | 2018-10-01 12:00:03 -0700 |
commit | ce8ff99711eea4e1b30b57eff77516fc36fea74f (patch) | |
tree | 47ec3718eee9749c4a55736938de872cf0d2a904 | |
parent | 789c0934585f1f9c342231e3132397b3ab07f7ae (diff) | |
download | device_generic_goldfish-opengl-ce8ff99711eea4e1b30b57eff77516fc36fea74f.tar.gz device_generic_goldfish-opengl-ce8ff99711eea4e1b30b57eff77516fc36fea74f.tar.bz2 device_generic_goldfish-opengl-ce8ff99711eea4e1b30b57eff77516fc36fea74f.zip |
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
-rw-r--r-- | system/gralloc/gralloc.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp index 0379d329..e3bf5d6f 100644 --- a/system/gralloc/gralloc.cpp +++ b/system/gralloc/gralloc.cpp @@ -802,7 +802,9 @@ static int gralloc_free(alloc_device_t* dev, 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; |