From d88a67c4c7b8b668ede8484033fbca70d09659fd Mon Sep 17 00:00:00 2001 From: Madhanraj Chelladurai Date: Wed, 6 Sep 2023 00:07:26 +0800 Subject: [PATCH] sdm660-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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gps/android/utils/battery_listener.cpp b/gps/android/utils/battery_listener.cpp index a6a498e4..64ce2c8e 100644 --- a/gps/android/utils/battery_listener.cpp +++ b/gps/android/utils/battery_listener.cpp @@ -194,7 +194,9 @@ BatteryListenerImpl::~BatteryListenerImpl() } } mDone = true; - mThread->join(); + if (NULL != mThread) { + mThread->join(); + } } void BatteryListenerImpl::serviceDied(uint64_t cookie __unused, @@ -211,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(); }