Fix issues reported by a static analyzer about using g_variant_iter_free() 37/128037/2 accepted/tizen/unified/20170504.114204 submit/tizen/20170504.080025
authorJiung Yu <jiung.yu@samsung.com>
Thu, 4 May 2017 06:49:07 +0000 (15:49 +0900)
committerJiung Yu <jiung.yu@samsung.com>
Thu, 4 May 2017 07:18:01 +0000 (16:18 +0900)
Description :
In definition is_valid_heap_iter(i), GVHI(i)->magic comes first

define is_valid_iter(i)        (i != NULL && \
                                 GVSI(i)->magic == GVSI_MAGIC)
define is_valid_heap_iter(i)   (GVHI(i)->magic == GVHI_MAGIC && \
                                 is_valid_iter(i))
Change-Id: I2af1421a3da3443ee5e9564aa469bc43d4894bd8
Signed-off-by: Yu jiung <jiung.yu@samsung.com>
packaging/asp-manager.spec
src/asp-manager-gdbus.c
src/tech/asp-tech-p2p.c

index 2c38bd1..a862757 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       asp-manager
 Summary:    ASP(application service platform) manager
-Version:    0.0.14
+Version:    0.0.15
 Release:    2
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
index f3d3114..d2e3d57 100755 (executable)
@@ -126,7 +126,8 @@ static gboolean __asp_manager_gdbus_advertise_service(AspService *object,
        if (!asp) {
                ASP_LOGE("Failed to get memory for asp structure");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
        DEBUG_PARAMS(parameters);
 
@@ -137,7 +138,8 @@ static gboolean __asp_manager_gdbus_advertise_service(AspService *object,
        if(!iter) {
                ASP_LOGE("Failed to get iter");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
 
        while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
@@ -202,7 +204,8 @@ static gboolean __asp_manager_gdbus_service_status_change(AspService *object,
        if (!asp) {
                ASP_LOGE("Failed to get memory for asp structure");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
        DEBUG_PARAMS(parameters);
 
@@ -211,7 +214,8 @@ static gboolean __asp_manager_gdbus_service_status_change(AspService *object,
        if(!iter) {
                ASP_LOGE("Failed to get iter");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
 
        while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
@@ -318,7 +322,8 @@ static gboolean __asp_manager_gdbus_seek_service(AspService *object,
        if (!asp) {
                ASP_LOGE("Failed to get memory for asp structure");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
        DEBUG_PARAMS(parameters);
 
@@ -329,7 +334,8 @@ static gboolean __asp_manager_gdbus_seek_service(AspService *object,
        if(!iter) {
                ASP_LOGE("Failed to get iter");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
 
        while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
@@ -489,7 +495,8 @@ static gboolean __asp_manager_gdbus_connect_session(AspSession *object,
        if (!asp) {
                ASP_LOGE("Failed to get memory for asp structure");
                ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
        DEBUG_PARAMS(parameters);
 
@@ -497,7 +504,8 @@ static gboolean __asp_manager_gdbus_connect_session(AspSession *object,
        if(!iter) {
                ASP_LOGE("Failed to get iter");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
 
        while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
@@ -596,7 +604,8 @@ static gboolean __asp_manager_gdbus_confirm_session(AspSession *object,
        if (!asp) {
                ASP_LOGE("Failed to get memory for asp structure");
                ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
        DEBUG_PARAMS(parameters);
 
@@ -604,7 +613,8 @@ static gboolean __asp_manager_gdbus_confirm_session(AspSession *object,
        if(!iter) {
                ASP_LOGE("Failed to get iter");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
 
        while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
@@ -819,7 +829,8 @@ static gboolean __asp_manager_gdbus_bound_port(AspSession *object,
        if (!asp) {
                ASP_LOGE("Failed to get memory for asp structure");
                ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
        DEBUG_PARAMS(parameters);
 
@@ -827,7 +838,8 @@ static gboolean __asp_manager_gdbus_bound_port(AspSession *object,
        if(!iter) {
                ASP_LOGE("Failed to get iter");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
 
        while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
@@ -898,7 +910,8 @@ static gboolean __asp_manager_gdbus_release_port(AspSession *object,
        if (!asp) {
                ASP_LOGE("Failed to get memory for asp structure");
                ASP_RETURN_SESSION_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
        DEBUG_PARAMS(parameters);
 
@@ -906,7 +919,8 @@ static gboolean __asp_manager_gdbus_release_port(AspSession *object,
        if(!iter) {
                ASP_LOGE("Failed to get iter");
                ASP_RETURN_SERVICE_ERR(invocation, -ASP_ERROR_OPERATION_FAILED);
-               goto out;
+               __ASP_LOG_FUNC_EXIT__;
+               return TRUE;
        }
 
        while (g_variant_iter_loop(iter, "{sv}", &key, &var)) {
index b3bc0fc..a29c1ea 100755 (executable)
@@ -591,7 +591,7 @@ void asp_tech_p2p_process_session_peer_ip(GDBusConnection *connection,
        guint8 session_mac[MAC_LEN] = {0,};
        guint8 service_mac[MAC_LEN] = {0,};
        guint32 session_id = 0;
-       gchar *peer_ip = NULL;
+       const gchar *peer_ip = NULL;
 
        if (!parameters) {
                __ASP_LOG_FUNC_EXIT__;
@@ -603,17 +603,18 @@ void asp_tech_p2p_process_session_peer_ip(GDBusConnection *connection,
                if (!g_strcmp0(key, "session_mac")) {
                        if (asp_dbus_unpack_ay(session_mac, var, MAC_LEN) < 0) {
                                g_variant_iter_free(iter);
-                               g_free(peer_ip);
                                return;
                        }
                } else if (!g_strcmp0(key, "session_id")) {
                        g_variant_get(var, "u", &session_id);
                } else if (!g_strcmp0(key, "service_mac")) {
-                       if (asp_dbus_unpack_ay(service_mac, var, MAC_LEN) < 0)
-                               return;
+                       if (asp_dbus_unpack_ay(service_mac, var, MAC_LEN) < 0) {
+                                g_variant_iter_free(iter);
+                                return;
+                        }
+
                } else if (!g_strcmp0(key, "assigned_ip_address")) {
-                       g_variant_get(var, "&s", &str);
-                       peer_ip = g_strdup(str);
+                       g_variant_get(var, "&s", &peer_ip);
                } else {
                        ;/* Do Nothing */
                }
@@ -622,7 +623,6 @@ void asp_tech_p2p_process_session_peer_ip(GDBusConnection *connection,
        if (peer_ip == NULL) {
                ASP_LOGE("Invalid peer IP address");
                g_variant_iter_free(iter);
-               g_free(peer_ip);
                return;
        }
 
@@ -633,7 +633,6 @@ void asp_tech_p2p_process_session_peer_ip(GDBusConnection *connection,
        }
 
        g_variant_iter_free(iter);
-       g_free(peer_ip);
 
        __ASP_LOG_FUNC_EXIT__;
        return;