From: Randy Xu Date: Wed, 5 Jul 2017 06:18:38 +0000 (+0800) Subject: Solve the composer service NULL pointer crash X-Git-Tag: android-x86-8.1-r1~25^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=35b5114be8da71c69fc8a1ff8fb457c912c0992f;p=android-x86%2Fframeworks-native.git Solve the composer service NULL pointer crash The callback functions are set nullptr in ComposerClient::~ComposerClient() ./composer/2.1/default/ComposerClient.cpp:160: mHal.enableCallback(false) However, the callbacks are still used in hwc2on1adaptor, it will cause segment fault. Bug: 64650599 Test: adb shell stop Change-Id: I92e6a6b42418e987a7ead041f2d95c194b6a16e8 Signed-off-by: Randy Xu Signed-off-by: Qiming Shi Signed-off-by: Yong Yao Signed-off-by: Gaurav Sarode --- diff --git a/libs/hwc2on1adapter/HWC2On1Adapter.cpp b/libs/hwc2on1adapter/HWC2On1Adapter.cpp index e1b9a8a6f1..77f06bbbe7 100644 --- a/libs/hwc2on1adapter/HWC2On1Adapter.cpp +++ b/libs/hwc2on1adapter/HWC2On1Adapter.cpp @@ -426,7 +426,13 @@ Error HWC2On1Adapter::registerCallback(Callback descriptor, std::unique_lock lock(mStateMutex); - mCallbacks[descriptor] = {callbackData, pointer}; + if (pointer != nullptr) { + mCallbacks[descriptor] = {callbackData, pointer}; + } else { + ALOGI("unregisterCallback(%s)", to_string(descriptor).c_str()); + mCallbacks.erase(descriptor); + return Error::None; + } bool hasPendingInvalidate = false; std::vector displayIds;