diff options
author | jomui <jongmun.woo@samsung.com> | 2016-06-17 16:12:34 +0900 |
---|---|---|
committer | jomui <jongmun.woo@samsung.com> | 2016-06-17 16:48:19 +0900 |
commit | 1237eaaf7fdfe7d23c5914bc0e0b3d49164769ef (patch) | |
tree | 5bd498d41eb0c78885ec31aff0304cc7e2cb6939 | |
parent | 360a271e1344d728063748c301a16340c2dfd5a9 (diff) | |
download | geofence-server-1237eaaf7fdfe7d23c5914bc0e0b3d49164769ef.tar.gz geofence-server-1237eaaf7fdfe7d23c5914bc0e0b3d49164769ef.tar.bz2 geofence-server-1237eaaf7fdfe7d23c5914bc0e0b3d49164769ef.zip |
fix memory leaksubmit/tizen/20160620.101352accepted/tizen/mobile/20160621.083809accepted/tizen/ivi/20160621.083829accepted/tizen/common/20160620.163922
Signed-off-by: jomui <jongmun.woo@samsung.com>
Change-Id: Id9ff7c35fe00d7c1caee127189bf44ab6418de0f
-rw-r--r-- | geofence-server/src/geofence_server.c | 40 | ||||
-rwxr-xr-x | geofence-server/src/geofence_server_db.c | 2 |
2 files changed, 25 insertions, 17 deletions
diff --git a/geofence-server/src/geofence_server.c b/geofence-server/src/geofence_server.c index c5e68c1..9b4d66d 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -1757,16 +1757,16 @@ static void dbus_update_place_cb(gint place_id, const gchar *app_id, const gchar return; } - place_info_s *place_info = (place_info_s *) g_malloc0(sizeof(place_info_s)); - if (place_info == NULL) { - LOGI_GEOFENCE("malloc fail for place id[%d]", place_id); - __emit_fence_event(geofence_server, place_id, -1, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_OUT_OF_MEMORY, GEOFENCE_MANAGE_PLACE_UPDATED); - return; - } + place_info_s *place_info = NULL; ret = geofence_manager_get_place_info(place_id, &place_info); - if (ret != FENCE_ERR_NONE) { - LOGI_GEOFENCE("Place_id does not exist or DB error in getting the place info for place_id[%d].", place_id); - __emit_fence_event(geofence_server, place_id, -1, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_ID_NOT_EXIST, GEOFENCE_MANAGE_PLACE_UPDATED); + if (ret != FENCE_ERR_NONE || place_info == NULL) { + if (ret == FENCE_ERR_INTERNAL) { + LOGI_GEOFENCE("malloc fail for place id[%d]", place_id); + __emit_fence_event(geofence_server, place_id, -1, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_OUT_OF_MEMORY, GEOFENCE_MANAGE_PLACE_UPDATED); + } else { + LOGI_GEOFENCE("Place_id does not exist or DB error in getting the place info for place_id[%d].", place_id); + __emit_fence_event(geofence_server, place_id, -1, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_ID_NOT_EXIST, GEOFENCE_MANAGE_PLACE_UPDATED); + } g_free(place_info); return; } @@ -1929,12 +1929,16 @@ static void dbus_remove_place_cb(gint place_id, const gchar *app_id, gpointer us return; } - place_info_s *place_info = - (place_info_s *) g_malloc0(sizeof(place_info_s)); + place_info_s *place_info = NULL; ret = geofence_manager_get_place_info(place_id, &place_info); - if (ret != FENCE_ERR_NONE) { - LOGI_GEOFENCE("Place_id does not exist or DB error in getting the place info for place_id[%d].", place_id); - __emit_fence_event(geofence_server, place_id, -1, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_ID_NOT_EXIST, GEOFENCE_MANAGE_PLACE_REMOVED); + if (ret != FENCE_ERR_NONE || place_info == NULL) { + if (ret == FENCE_ERR_INTERNAL) { + LOGI_GEOFENCE("malloc fail for place id[%d]", place_id); + __emit_fence_event(geofence_server, place_id, -1, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_OUT_OF_MEMORY, GEOFENCE_MANAGE_PLACE_REMOVED); + } else { + LOGI_GEOFENCE("Place_id does not exist or DB error in getting the place info for place_id[%d].", place_id); + __emit_fence_event(geofence_server, place_id, -1, ACCESS_TYPE_UNKNOWN, app_id, GEOFENCE_SERVER_ERROR_ID_NOT_EXIST, GEOFENCE_MANAGE_PLACE_REMOVED); + } g_free(place_info); return; } @@ -2434,12 +2438,16 @@ static GVariant *dbus_get_geofences_cb(int place_id, const gchar *app_id, int *f ret = geofence_manager_get_fence_list_from_db(&count, &fence_list, -1); } else { ret = geofence_manager_get_place_info(place_id, &place_info); - if (ret != FENCE_ERR_NONE) { + if (ret != FENCE_ERR_NONE || place_info == NULL) { LOGE("Error getting the place info for place_id[%d]", place_id); /* Send ZERO data gvariant*/ - *errorCode = GEOFENCE_SERVER_ERROR_DATABASE; + if (ret == FENCE_ERR_INTERNAL) + *errorCode = GEOFENCE_SERVER_ERROR_OUT_OF_MEMORY; + else + *errorCode = GEOFENCE_SERVER_ERROR_DATABASE; *fenceCnt = fence_cnt; g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + g_free(place_info); return g_variant_builder_end(&b); } if ((place_info != NULL) && (place_info->access_type == ACCESS_TYPE_PRIVATE)) { diff --git a/geofence-server/src/geofence_server_db.c b/geofence-server/src/geofence_server_db.c index fabe33c..26273be 100755 --- a/geofence-server/src/geofence_server_db.c +++ b/geofence-server/src/geofence_server_db.c @@ -1359,7 +1359,7 @@ int geofence_manager_get_place_info(int place_id, place_info_s **place_info) return FENCE_ERR_SQLITE_FAIL; } *place_info = (place_info_s *)g_malloc0(sizeof(place_info_s)); - g_return_val_if_fail(*place_info, FENCE_ERR_INVALID_PARAMETER); + g_return_val_if_fail(*place_info, FENCE_ERR_INTERNAL); data_name = (char *)sqlite3_column_text(state, ++index); if (!data_name || !strlen(data_name)) |