summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhanraj Chelladurai <quic_mchellad@quicinc.com>2021-11-30 10:46:41 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2021-12-19 07:16:20 -0800
commit0131ba9e4efce6234f07158e41391aefc713bb1b (patch)
treee896b1e3c16f9a3093777a566759c80db7d047d5
parentd1fe0cea724eeae0faf1e7d4d25a6864940baed4 (diff)
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
-rw-r--r--android/utils/battery_listener.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/android/utils/battery_listener.cpp b/android/utils/battery_listener.cpp
index 0d5cd03..b144966 100644
--- a/android/utils/battery_listener.cpp
+++ b/android/utils/battery_listener.cpp
@@ -180,16 +180,19 @@ BatteryListenerImpl::~BatteryListenerImpl()
{
{
std::lock_guard<std::mutex> _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,
@@ -206,7 +209,9 @@ void BatteryListenerImpl::serviceDied(uint64_t cookie __unused,
}
mHealth = NULL;
mCond.notify_one();
- mThread->join();
+ if (NULL != mThread) {
+ mThread->join();
+ }
std::lock_guard<std::mutex> _l(mLock);
init();
}