Check Null on call to LocationAPI::addGeofence

We need to handle the case where addGeofence returns
Null, which can happen on error conditions, like when
dlopen/dlsym libgeofence.so fails

Bug: 36407968
CRs-fixed: 2022286
Change-Id: Ib612d92b77cf5532ad19154c57ee0545674d88f9
This commit is contained in:
Dante Russo 2017-03-20 15:04:36 -07:00 committed by Gerrit - the friendly Code Review server
parent af318504e2
commit 2e87b20579
2 changed files with 13 additions and 9 deletions

View file

@ -100,7 +100,10 @@ void GeofenceAPIClient::geofenceAdd(uint32_t geofence_id, double latitude, doubl
data.longitude = longitude; data.longitude = longitude;
data.radius = radius_meters; data.radius = radius_meters;
locAPIAddGeofences(1, &geofence_id, &options, &data); LocationError err = (LocationError)locAPIAddGeofences(1, &geofence_id, &options, &data);
if (LOCATION_ERROR_SUCCESS != err) {
onAddGeofencesCb(1, &err, &geofence_id);
}
} }
void GeofenceAPIClient::geofencePause(uint32_t geofence_id) void GeofenceAPIClient::geofencePause(uint32_t geofence_id)

View file

@ -409,6 +409,7 @@ uint32_t LocationAPIClientBase::locAPIAddGeofences(
delete requests; delete requests;
} }
uint32_t* sessions = mLocationAPI->addGeofences(count, options, data); uint32_t* sessions = mLocationAPI->addGeofences(count, options, data);
if (sessions) {
LOC_LOGI("%s:%d] start new sessions: %p", __FUNCTION__, __LINE__, sessions); LOC_LOGI("%s:%d] start new sessions: %p", __FUNCTION__, __LINE__, sessions);
requests = new RequestQueue(-1); requests = new RequestQueue(-1);
requests->push(new AddGeofencesRequest(*this)); requests->push(new AddGeofencesRequest(*this));
@ -417,10 +418,10 @@ uint32_t LocationAPIClientBase::locAPIAddGeofences(
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask); mGeofenceBiDict.set(ids[i], sessions[i], options[i].breachTypeMask);
} }
pthread_mutex_unlock(&mMutex);
retVal = LOCATION_ERROR_SUCCESS; retVal = LOCATION_ERROR_SUCCESS;
} }
pthread_mutex_unlock(&mMutex);
}
return retVal; return retVal;
} }