Coverity issues 89/152989/3
authorchanywa <cbible.kim@samsung.com>
Wed, 27 Sep 2017 12:29:08 +0000 (21:29 +0900)
committerSeechan Kim <cbible.kim@samsung.com>
Thu, 28 Sep 2017 01:47:02 +0000 (01:47 +0000)
Change-Id: I459535e9828bb89e75e46bf5773fc34256e3014d

src/mapzen/mapzen_geocode.c
src/mapzen/mapzen_place.c
src/mapzen/mapzen_queue.c

index 9d912df..d2d4c5c 100644 (file)
@@ -31,8 +31,8 @@
 
 int query_geocode_within_bounding_box(gchar *maps_key, char *address, coords_s top_left, coords_s bottom_right, int num_results, gpointer user_data)
 {
-       char url[1024];
-       char tmpStr[512];
+       char url[1024] = "";
+       char tmpStr[512] = "";
 
        if (maps_key != NULL)
                snprintf(tmpStr, sizeof(tmpStr), GEOCODE_URL, maps_key);
@@ -59,8 +59,8 @@ int query_geocode_within_bounding_box(gchar *maps_key, char *address, coords_s t
 
 int query_geocode_within_circle(gchar *maps_key, char *address, coords_s center, double radius, int num_results, gpointer user_data)
 {
-       char url[1024];
-       char tmpStr[512];
+       char url[1024] = "";
+       char tmpStr[512] = "";
 
        if (maps_key != NULL)
                snprintf(tmpStr, sizeof(tmpStr), GEOCODE_URL, maps_key);
@@ -89,8 +89,8 @@ int query_geocode_within_circle(gchar *maps_key, char *address, coords_s center,
 int query_geocode(gchar *maps_key, char *address, int num_results, gpointer user_data)
 {
        MAP_DEBUG("geocode address : %s", address);
-       char url[1024];
-       char tmpStr[512];
+       char url[1024] = "";
+       char tmpStr[512] = "";
 
        if (maps_key != NULL)
                snprintf(tmpStr, sizeof(tmpStr), GEOCODE_URL, maps_key);
index 4c6da64..8282ab9 100644 (file)
@@ -33,8 +33,8 @@
 
 int query_places(gchar *maps_key, gchar *search_str, gchar *categories, mapzen_boundary_s *boundary, int num_res, gpointer user_data, mapzen_req_type type)
 {
-       char url[1024];
-       char tmpStr[512];
+       char url[1024] = "";
+       char tmpStr[512] = "";
 
        if (search_str != NULL || boundary->type == MAPZEN_BOUNDARY_RECT) {
                if (maps_key != NULL)
@@ -99,13 +99,14 @@ int query_places(gchar *maps_key, gchar *search_str, gchar *categories, mapzen_b
 
 int query_place_details(gchar *maps_key, gchar *ids, gpointer user_data)
 {
-       char url[1024];
-       char tmpStr[512];
+       char url[1024] = "";
+       char tmpStr[512] = "";
 
        if (maps_key != NULL)
                snprintf(tmpStr, sizeof(tmpStr), PLACE_DETAILS_URL, maps_key);
-       else snprintf(tmpStr, sizeof(tmpStr), PLACE_DETAILS_URL, "null");
-               STRCPY(url, tmpStr);
+       else
+               snprintf(tmpStr, sizeof(tmpStr), PLACE_DETAILS_URL, "null");
+       STRCPY(url, tmpStr);
 
        if (ids != NULL) {
                char *encoded = curl_escape(ids, 0);
index 87c1f08..2dd5d30 100644 (file)
@@ -70,6 +70,8 @@ int add_to_geocode_list(mapzen_geocode_req_s *req_details, mapzen_geocode_cb cal
                        else
                                requestList = g_list_insert_before(requestList, NULL, (gpointer)req);
                        pthread_mutex_unlock(&__requestLock);
+               } else {
+                       g_free(req);
                }
        }
 
@@ -102,6 +104,8 @@ int add_to_revgeocode_list(mapzen_revgeocode_req_s *req_details, mapzen_reverse_
                        else
                                requestList = g_list_insert_before(requestList, NULL, (gpointer)req);
                        pthread_mutex_unlock(&__requestLock);
+               } else {
+                       g_free(req);
                }
        }
 
@@ -134,6 +138,8 @@ int add_to_place_list(mapzen_search_req_s *req_details, mapzen_place_search_cb c
                        else
                                requestList = g_list_insert_before(requestList, NULL, (gpointer)req);
                        pthread_mutex_unlock(&__requestLock);
+               } else {
+                       g_free(req);
                }
        }
 
@@ -166,6 +172,8 @@ int add_to_place_details_list(mapzen_get_details_req_s *req_details, mapzen_get_
                        else
                                requestList = g_list_insert_before(requestList, NULL, (gpointer)req);
                        pthread_mutex_unlock(&__requestLock);
+               } else {
+                       g_free(req);
                }
        }
 
@@ -202,6 +210,8 @@ int add_to_places_list(mapzen_search_req_s *req_details, mapzen_place_list_searc
                        else
                                requestList = g_list_insert_before(requestList, NULL, (gpointer)req);
                        pthread_mutex_unlock(&__requestLock);
+               } else {
+                       g_free(req);
                }
        }
 
@@ -238,8 +248,9 @@ int add_to_route_list(mapzen_route_req_s *req_details, mapzen_route_cb callback,
                        else
                                requestList = g_list_insert_before(requestList, NULL, (gpointer)req);
                        pthread_mutex_unlock(&__requestLock);
+               } else {
+                       g_free(req);
                }
-
        }
 
        return MAPZEN_ERROR_NONE;
@@ -489,7 +500,7 @@ mapzen_request_s *get_next_request()
        return NULL;
 }
 
-static gboolean __timeout_cb(gpointer data)
+static gboolean __timeout_cb(gpointer user_data)
 {
        MAP_DEBUG("timeout_cb");
        __response_timer_running = true;