From ce6e742eb6a08bb072af51bd5be7b8d6844713ed Mon Sep 17 00:00:00 2001 From: Peng Xu Date: Thu, 4 May 2017 17:14:42 -0700 Subject: [PATCH] Only convert valid SharedMemInfo This CL avoids passing nullptr to underlying HAL and cause SEGFAULT. Bug: 37589989 Test: compiles and VTS passing Change-Id: Ic44409e64466e54a3a3027721897c0755ba34fc7 Merged-In: Ic44409e64466e54a3a3027721897c0755ba34fc7 --- sensors/1.0/default/convert.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sensors/1.0/default/convert.cpp b/sensors/1.0/default/convert.cpp index 047374f9ea..a5747d42f9 100644 --- a/sensors/1.0/default/convert.cpp +++ b/sensors/1.0/default/convert.cpp @@ -376,6 +376,10 @@ bool convertFromSharedMemInfo(const SharedMemInfo& memIn, sensors_direct_mem_t * return false; } + if (memIn.memoryHandle == nullptr) { + return false; + } + memOut->size = memIn.size; memOut->handle = memIn.memoryHandle; return true;