Fix __dispatch_get_socket_pair necessary bundle free bug. 48/53748/1 accepted/tizen/mobile/20151210.024522 accepted/tizen/tv/20151210.021456 accepted/tizen/wearable/20151210.024418 submit/tizen/20151209.065705
authorhyunho kang <hhstark.kang@samsung.com>
Wed, 9 Dec 2015 05:56:35 +0000 (14:56 +0900)
committerhyunho kang <hhstark.kang@samsung.com>
Wed, 9 Dec 2015 05:56:35 +0000 (14:56 +0900)
Change-Id: I3f0ad6084b9875e54603da0917c7d0794f9b4e70
Signed-off-by: hyunho kang <hhstark.kang@samsung.com>
am_daemon/amd_request.c

index e33c144..89b344c 100644 (file)
@@ -378,7 +378,6 @@ static int __dispatch_get_socket_pair(int clifd, const app_pkt_t *pkt, struct uc
        caller = (char *)bundle_get_val(kb, AUL_K_CALLER_APPID);
        callee = (char *)bundle_get_val(kb, AUL_K_CALLEE_APPID);
        datacontrol_type = (char *)bundle_get_val(kb, "DATA_CONTOL_TYPE");
-       bundle_free(kb);
 
        socket_pair_key_len = strlen(caller) + strlen(callee) + 2;
 
@@ -400,9 +399,7 @@ static int __dispatch_get_socket_pair(int clifd, const app_pkt_t *pkt, struct uc
 
                        if (handles)
                                free(handles);
-                       if (socket_pair_key)
-                               free(socket_pair_key);
-                       return -1;
+                       goto err_out;
                }
 
                if (handles[0] == -1) {
@@ -411,9 +408,7 @@ static int __dispatch_get_socket_pair(int clifd, const app_pkt_t *pkt, struct uc
 
                        if (handles)
                                free(handles);
-                       if (socket_pair_key)
-                               free(socket_pair_key);
-                       return -1;
+                       goto err_out;
                }
                g_hash_table_insert(__socket_pair_hash, strdup(socket_pair_key),
                                handles);
@@ -436,6 +431,7 @@ static int __dispatch_get_socket_pair(int clifd, const app_pkt_t *pkt, struct uc
                        if (msglen < 0) {
                                _E("Error[%d]: while sending message\n", -msglen);
                                __send_result_to_client(clifd, -1);
+                               g_hash_table_remove(__socket_pair_hash, socket_pair_key);
                                goto err_out;
                        }
                        close(handles[0]);
@@ -450,6 +446,7 @@ static int __dispatch_get_socket_pair(int clifd, const app_pkt_t *pkt, struct uc
                        if (msglen < 0) {
                                _E("Error[%d]: while sending message\n", -msglen);
                                __send_result_to_client(clifd, -1);
+                               g_hash_table_remove(__socket_pair_hash, socket_pair_key);
                                goto err_out;
                        }
                        close(handles[1]);
@@ -463,13 +460,16 @@ static int __dispatch_get_socket_pair(int clifd, const app_pkt_t *pkt, struct uc
        SECURE_LOGD("send_message msglen : [%d]\n", msglen);
        if (socket_pair_key)
                free(socket_pair_key);
+       if (kb)
+               bundle_free(kb);
 
        return 0;
 
 err_out:
-       g_hash_table_remove(__socket_pair_hash, socket_pair_key);
        if (socket_pair_key)
                free(socket_pair_key);
+       if (kb)
+               bundle_free(kb);
 
        return -1;
 }