From 0c0ae20c682b28270eb4c1a4662743148dee1b5f Mon Sep 17 00:00:00 2001 From: Madhanraj Chelladurai Date: Fri, 1 Sep 2023 18:22:06 +0200 Subject: [PATCH] sm6150-common: gps: Add NULL check before object access Correct the NULL check code block and add NULL check before object access. Change-Id: Ic41b781b41fb4e21bbff8801d500a41a6d7219d0 CRs-fixed: 3084543 --- gps/android/utils/battery_listener.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gps/android/utils/battery_listener.cpp b/gps/android/utils/battery_listener.cpp index 9cbfabd..64ce2c8 100644 --- a/gps/android/utils/battery_listener.cpp +++ b/gps/android/utils/battery_listener.cpp @@ -184,16 +184,19 @@ BatteryListenerImpl::~BatteryListenerImpl() { { std::lock_guard _l(mLock); - if (mHealth != NULL) + if (mHealth != NULL) { mHealth->unregisterCallback(this); auto r = mHealth->unlinkToDeath(this); if (!r.isOk() || r == false) { LOC_LOGe("Transaction error in unregister to HealthHAL death: %s", r.description().c_str()); } + } } mDone = true; - mThread->join(); + if (NULL != mThread) { + mThread->join(); + } } void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, @@ -210,7 +213,9 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, } mHealth = NULL; mCond.notify_one(); - mThread->join(); + if (NULL != mThread) { + mThread->join(); + } std::lock_guard _l(mLock); init(); }