Fix crash at gnss bugreport caused by empty report

Adding an empty check for gnss time information before
generating a gnss bugreport to avoid null object access.

Bug: 37259715

Change-Id: Ic507acbcc8b5949c4304ad76a3032add5893d099
CRs-Fixed: 2032932
This commit is contained in:
Katz Yamada 2017-04-12 14:04:29 -07:00 committed by Kevin Tang
parent f3a58cea24
commit 3b9f65652b

View file

@ -2691,10 +2691,12 @@ bool GnssAdapter::getDebugReport(GnssDebugReport& r)
r.mLocation.mLocation.speed);
// time block
r.mTime.size = sizeof(r.mTime);
if(!reports.mBestPosition.empty()) {
r.mTime.size = sizeof(r.mTime);
r.mTime.timeEstimate = reports.mBestPosition.back().mUtcTime.tv_sec;
r.mTime.timeUncertaintyNs = (float)(reports.mTimeAndClock.back().mTimeUnc);
r.mTime.timeEstimate = reports.mBestPosition.back().mUtcTime.tv_sec;
}
if(!reports.mTimeAndClock.empty()) {
r.mTime.timeUncertaintyNs = (float)(reports.mTimeAndClock.back().mTimeUnc);
}
LOC_LOGV("getDebugReport - timeestimate=%lld", r.mTime.timeEstimate);