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.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)

View file

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