Resolved ASAN issues
[platform/core/api/location-manager.git] / src / locations.c
index 36165c5..942f4c1 100755 (executable)
@@ -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) {