From: Abhimanyu Swami Date: Mon, 23 Sep 2019 06:17:28 +0000 (+0530) Subject: Resolved ASAN issues X-Git-Tag: accepted/tizen/5.5/unified/20191031.031205^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Ftizen_5.5_wearable_hotfix;p=platform%2Fcore%2Fapi%2Flocation-manager.git Resolved ASAN issues Change-Id: If704140344bda71e3257f7aed483b76f6507407f Signed-off-by: Abhimanyu Swami --- diff --git a/src/location_internal.c b/src/location_internal.c index 054a4a0..ede0a44 100644 --- a/src/location_internal.c +++ b/src/location_internal.c @@ -179,8 +179,12 @@ int __set_callback(_location_event_e type, location_manager_h manager, void *cal LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); location_manager_s *handle = (location_manager_s *) manager; - handle->user_cb[type] = callback; - handle->user_data[type] = user_data; + if (handle != NULL){ + handle->user_cb[type] = callback; + handle->user_data[type] = user_data; + } + else + LOCATIONS_LOGE("Null Handle"); LOCATIONS_LOGD("event type : %d", type); return LOCATIONS_ERROR_NONE; } @@ -189,8 +193,12 @@ int __unset_callback(_location_event_e type, location_manager_h manager) { LOCATIONS_NULL_ARG_CHECK(manager); location_manager_s *handle = (location_manager_s *) manager; - handle->user_cb[type] = NULL; - handle->user_data[type] = NULL; + if (handle != NULL){ + handle->user_cb[type] = NULL; + handle->user_data[type] = NULL; + } + else + LOCATIONS_LOGE("Null Handle"); LOCATIONS_LOGD("event type : %d", type); return LOCATIONS_ERROR_NONE; } diff --git a/src/locations.c b/src/locations.c index 36165c5..942f4c1 100755 --- a/src/locations.c +++ b/src/locations.c @@ -573,6 +573,7 @@ EXPORT_API int location_manager_destroy(location_manager_h manager) return __convert_error_code(ret); //LCOV_EXCL_LINE free(handle); + handle = NULL; return LOCATIONS_ERROR_NONE; } @@ -738,7 +739,10 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_ location_manager_s *handle = (location_manager_s *) manager; LocationMethod _method = LOCATION_METHOD_NONE; - g_object_get(handle->object, "method", &_method, NULL); + if (handle != NULL) + g_object_get(handle->object, "method", &_method, NULL); + else + LOCATIONS_LOGE("Null Handle"); switch (_method) { case LOCATION_METHOD_NONE: *method = LOCATIONS_METHOD_NONE; @@ -952,7 +956,10 @@ EXPORT_API int location_manager_get_last_location(location_manager_h manager, do LocationPosition *last_pos = NULL; LocationVelocity *last_vel = NULL; LocationAccuracy *last_acc = NULL; - ret = location_get_last_position_ext(handle->object, &last_pos, &last_vel, &last_acc); + if (handle != NULL) + ret = location_get_last_position_ext(handle->object, &last_pos, &last_vel, &last_acc); + else + LOCATIONS_LOGE("Null Handle"); if (ret != LOCATION_ERROR_NONE) return __convert_error_code(ret); //LCOV_EXCL_LINE @@ -1090,7 +1097,10 @@ EXPORT_API int location_manager_set_location_changed_cb(location_manager_h manag LOCATIONS_CHECK_CONDITION(interval >= 1 && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); LOCATIONS_NULL_ARG_CHECK(manager); location_manager_s *handle = (location_manager_s *) manager; - g_object_set(handle->object, "loc-interval", interval, NULL); + if (handle != NULL) + g_object_set(handle->object, "loc-interval", interval, NULL); + else + LOCATIONS_LOGE("Null Handle"); return __set_callback(_LOCATIONS_EVENT_TYPE_POS_VEL, manager, callback, user_data); } @@ -1257,8 +1267,11 @@ EXPORT_API int gps_status_get_nmea(location_manager_h manager, char **nmea) LOCATIONS_NULL_ARG_CHECK(nmea); location_manager_s *handle = (location_manager_s *) manager; char *nmea_data; - - int ret = location_get_nmea(handle->object, &nmea_data); + int ret = 0; + if (handle != NULL) + ret = location_get_nmea(handle->object, &nmea_data); + else + LOCATIONS_LOGE("Null Handle"); if (ret != LOCATION_ERROR_NONE || nmea == NULL) { //LCOV_EXCL_START if (ret == LOCATION_ERROR_NOT_ALLOWED) {