summaryrefslogtreecommitdiff
path: root/location/LocationAPIClientBase.cpp
diff options
context:
space:
mode:
authorSaurabh Srivastava <ssrivast@codeaurora.org>2017-07-03 17:07:37 +0530
committerSaurabh Srivastava <ssrivast@codeaurora.org>2017-07-03 17:07:37 +0530
commit8cf201ae2ad75a5292e322f12daec5b5ba6d029b (patch)
treee792a57f1ab237383e9d4be6f7bba0d20afa85cd /location/LocationAPIClientBase.cpp
parent15ae65c5cc01ea67292f1d357b0294c51c396dd6 (diff)
downloadgps-8cf201ae2ad75a5292e322f12daec5b5ba6d029b.tar.gz
Adding KW warning fixes
Change-Id: I03a09abdfc4224d59d3ddb467d0314e644fe4fe0 CRs-Fixed: 2062522
Diffstat (limited to 'location/LocationAPIClientBase.cpp')
-rw-r--r--location/LocationAPIClientBase.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/location/LocationAPIClientBase.cpp b/location/LocationAPIClientBase.cpp
index bf1a8ad..56ac9cc 100644
--- a/location/LocationAPIClientBase.cpp
+++ b/location/LocationAPIClientBase.cpp
@@ -583,6 +583,11 @@ void LocationAPIClientBase::locAPIRemoveGeofences(size_t count, uint32_t* ids)
pthread_mutex_lock(&mMutex);
if (mLocationAPI) {
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
+ if (sessions == NULL) {
+ LOC_LOGE("%s:%d] Failed to allocate %d bytes !",
+ __FUNCTION__, __LINE__, sizeof(uint32_t) * count);
+ return;
+ }
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
size_t j = 0;
@@ -612,6 +617,11 @@ void LocationAPIClientBase::locAPIModifyGeofences(
pthread_mutex_lock(&mMutex);
if (mLocationAPI) {
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
+ if (sessions == NULL) {
+ LOC_LOGE("%s:%d] Failed to allocate %d bytes !",
+ __FUNCTION__, __LINE__, sizeof(uint32_t) * count);
+ return;
+ }
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
size_t j = 0;
@@ -641,6 +651,11 @@ void LocationAPIClientBase::locAPIPauseGeofences(size_t count, uint32_t* ids)
pthread_mutex_lock(&mMutex);
if (mLocationAPI) {
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
+ if (sessions == NULL) {
+ LOC_LOGE("%s:%d] Failed to allocate %d bytes !",
+ __FUNCTION__, __LINE__, sizeof(uint32_t) * count);
+ return;
+ }
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
size_t j = 0;
@@ -670,6 +685,11 @@ void LocationAPIClientBase::locAPIResumeGeofences(
pthread_mutex_lock(&mMutex);
if (mLocationAPI) {
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
+ if (sessions == NULL) {
+ LOC_LOGE("%s:%d] Failed to allocate %d bytes !",
+ __FUNCTION__, __LINE__, sizeof(uint32_t) * count);
+ return;
+ }
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
size_t j = 0;
@@ -703,6 +723,11 @@ void LocationAPIClientBase::locAPIRemoveAllGeofences()
std::vector<uint32_t> sessionsVec = mGeofenceBiDict.getAllSessions();
size_t count = sessionsVec.size();
uint32_t* sessions = (uint32_t*)malloc(sizeof(uint32_t) * count);
+ if (sessions == NULL) {
+ LOC_LOGE("%s:%d] Failed to allocate %d bytes !",
+ __FUNCTION__, __LINE__, sizeof(uint32_t) * count);
+ return;
+ }
if (mRequestQueues[REQUEST_GEOFENCE].getSession() == GEOFENCE_SESSION_ID) {
size_t j = 0;
@@ -747,6 +772,13 @@ void LocationAPIClientBase::beforeGeofenceBreachCb(
size_t n = geofenceBreachNotification.count;
geofenceBreachCallback genfenceCallback = nullptr;
+ if (ids == NULL) {
+ LOC_LOGE("%s:%d] Failed to alloc %d bytes",
+ __FUNCTION__, __LINE__,
+ sizeof(uint32_t) * geofenceBreachNotification.count);
+ return;
+ }
+
pthread_mutex_lock(&mMutex);
if (mGeofenceBreachCallback != nullptr) {
size_t count = 0;