fix memory leak 60/117160/2 accepted/tizen/3.0/common/20170306.135514 accepted/tizen/3.0/ivi/20170305.222011 accepted/tizen/3.0/mobile/20170305.221940 accepted/tizen/3.0/wearable/20170305.221956 submit/tizen_3.0/20170303.055346
authorjkjo92 <jkjo92@samsung.com>
Fri, 3 Mar 2017 05:25:42 +0000 (14:25 +0900)
committerjkjo92 <jkjo92@samsung.com>
Fri, 3 Mar 2017 05:31:43 +0000 (14:31 +0900)
Change-Id: Ib77eb032791368186a24c44b448a424f95d54493
Signed-off-by: jkjo92 <jkjo92@samsung.com>
client/fido_uaf_client.c
server/fido_app_id_handler.c [changed mode: 0644->0755]
server/fido_asm_plugin_manager.c [changed mode: 0644->0755]
server/fido_server.c

index 8ed130d..8246266 100755 (executable)
@@ -86,11 +86,6 @@ _fido_uaf_process_operation_reply(GObject *object, GAsyncResult *res, gpointer u
 
        GError *dbus_err = NULL;
 
-       if (user_data == NULL) {
-               _ERR("Can not proceed since callback data is NULL");
-       return;
-       }
-
        _fido_process_cb_data_s *cb_data = (_fido_process_cb_data_s *)user_data;
 
        if (cb_data->cb == NULL) {
old mode 100644 (file)
new mode 100755 (executable)
index 90637ea..9f4c50a
@@ -575,6 +575,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati
        */
        cb_data->caller_app_id = __get_tz_facet_id_of_caller(app_id, invocation);
        if (cb_data->caller_app_id == NULL) {
+               SAFE_DELETE(app_id);
                SAFE_DELETE(cb_data);
                return FIDO_ERROR_PERMISSION_DENIED;
        }
@@ -588,6 +589,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati
                _DBG("UAF msg does not have appID");
                cb_data->real_app_id = __get_tz_facet_id_of_caller(app_id, invocation);
                g_timeout_add(2, __timer_expired, cb_data);
+               SAFE_DELETE(app_id);
                return FIDO_ERROR_NONE;
        }
 
@@ -597,7 +599,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati
 
                cb_data->real_app_id = strdup(uaf_app_id);
                g_timeout_add(2, __timer_expired, cb_data);
-
+               SAFE_DELETE(app_id);
                return FIDO_ERROR_NONE;
        }
 
@@ -606,6 +608,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati
 
                _INFO("soup_uri_new failed");
                _free_app_id_cb_data(cb_data);
+               SAFE_DELETE(app_id);
                return FIDO_ERROR_PERMISSION_DENIED;
        }
 
@@ -616,11 +619,13 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati
        const char *scheme = soup_uri_get_scheme(parsed_uri);
        if (scheme == NULL) {
                 _free_app_id_cb_data(cb_data);
+                SAFE_DELETE(app_id);
                 return FIDO_ERROR_INVALID_PARAMETER;
        }
 
        if (strcmp(SOUP_URI_SCHEME_HTTPS, scheme) != 0) {
                _free_app_id_cb_data(cb_data);
+               SAFE_DELETE(app_id);
                return FIDO_ERROR_INVALID_PARAMETER;
        }
 
@@ -653,5 +658,6 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati
 
        _INFO("Added in soup_session_queue_message");
 
+       SAFE_DELETE(app_id);
        return FIDO_ERROR_NONE;
 }
old mode 100644 (file)
new mode 100755 (executable)
index 46022f9..6662930
@@ -351,6 +351,7 @@ _on_asm_dbus_reply(GObject *proxy, GAsyncResult *res, gpointer user_data)
        if (dbus_resp != NULL)
                g_variant_unref(dbus_resp);
 
+       SAFE_DELETE(asm_response_json);
        SAFE_DELETE(cb_data);
 }
 
@@ -459,6 +460,7 @@ _asm_ipc_send_sync(const char *asm_id, const char *asm_req)
                        NULL,
                        &error);
 
+       SAFE_DELETE(method_name);
        if (error != NULL)
                _ERR("g_dbus_proxy_call_sync failed [%s]", error->message);
        else
@@ -473,6 +475,6 @@ _asm_ipc_send_sync(const char *asm_id, const char *asm_req)
 
        //g_variant_unref (_ret);
 
-CATCH :
+CATCH:
        return asm_res_json;
 }
index 65b2a2b..9cf0f6e 100755 (executable)
@@ -168,6 +168,7 @@ _asm_get_info_cb(GList *asm_resp_list, void *user_data)
                } else
                   __send_discover_response(dbus_info->dbus_obj, dbus_info->invocation, FIDO_ERROR_NOT_SUPPORTED,
                                                                                   NULL, 0);
+                  free(dbus_info);
        }
 
        if (asm_resp_list != NULL)
@@ -234,6 +235,8 @@ _discover_response_intermediate_cb(GList *asm_response_list, void *user_data)
 
        if (asm_response_list != NULL)
                g_list_free_full(asm_response_list, __free_asm_discover_response_list_item);
+
+       SAFE_DELETE(cb_data);
 }
 
 static int
@@ -661,8 +664,10 @@ _asm_response_dereg_process(int error_code, const char *asm_response_json, void
        _dereg_q_t *dereg_q = (_dereg_q_t*)(user_data);
        _process_cb_data_t *cb_data = (_process_cb_data_t*)(dereg_q->cb_data);
 
-       if (cb_data == NULL)
+       if (cb_data == NULL) {
+               SAFE_DELETE(dereg_q);
                return;
+       }
 
        /*Process next dereg*/
        GQueue *q = (GQueue*) (dereg_q->dereg_asm_in_q);
@@ -678,6 +683,8 @@ _asm_response_dereg_process(int error_code, const char *asm_response_json, void
                g_queue_free(dereg_q->dereg_asm_in_q);
                dereg_q->dereg_asm_in_q = NULL;
                _INFO("After Deleting dereg_asm_in_q");
+
+               SAFE_DELETE(dereg_q);
        }
 
 }
@@ -688,14 +695,17 @@ __process_dereg_queue(_dereg_q_t *dereg_q)
        _INFO("__process_dereg_queue");
 
        GQueue *q = dereg_q->dereg_asm_in_q;
-       if (q == NULL)
+       if (q == NULL) {
+               SAFE_DELETE(dereg_q);
                return;
+       }
 
        if (g_queue_is_empty(q) == true) {
                _INFO("Deleting dereg_asm_in_q");
                g_queue_free(dereg_q->dereg_asm_in_q);
                dereg_q->dereg_asm_in_q = NULL;
                _INFO("After Deleting dereg_asm_in_q");
+               SAFE_DELETE(dereg_q);
                return;
        }
 
@@ -722,6 +732,7 @@ __process_dereg_queue(_dereg_q_t *dereg_q)
                                          asm_req_json, _asm_response_dereg_process, dereg_q);
        } else {
                _send_process_response(cb_data, FIDO_ERROR_INVALID_PARAMETER, NULL);
+               SAFE_DELETE(dereg_q);
        }
 
        _free_matched_auth_dereg(dereg_data);
@@ -1401,6 +1412,7 @@ main(void)
        __initialize();
 
        g_main_loop_run(mainloop);
+       g_main_loop_unref(mainloop);
 
        _INFO("Ending FIDO SVC");
        return 0;