Fix memory leak 42/198142/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 21 Jan 2019 10:21:32 +0000 (19:21 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 21 Jan 2019 10:21:32 +0000 (19:21 +0900)
Change-Id: Ib930c35f9455682056b17b49d6709bb6dbf071e1
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/autofill-daemon.c

index 6bfb34760085b9ce2ae7979fa88bc66eb0d4f75b..55e8298cb7a89fe8d674bf3003b62fbe9d0edb90 100644 (file)
@@ -29,6 +29,8 @@
 #include "autofill_config.h"
 
 static rpc_port_proxy_AutofillSvcPort_h svc_rpc_h = NULL;
+static rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_received_cb_h = NULL;
+static rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb_h = NULL;
 
 static int connect_service();
 
@@ -585,8 +587,16 @@ static void __on_connected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data)
 {
     LOGI("[__RPC_PORT__] connected");
 
-    rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_received_cb_h = rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_create(__fill_response_recv_cb, false, NULL);
-    rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb_h = rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_create(__auth_info_recv_cb, false, NULL);
+    if (fill_response_received_cb_h) {
+        free(fill_response_received_cb_h);
+    }
+
+    if (auth_info_cb_h) {
+        free(auth_info_cb_h);
+    }
+
+    fill_response_received_cb_h = rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_create(__fill_response_recv_cb, false, NULL);
+    auth_info_cb_h = rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_create(__auth_info_recv_cb, false, NULL);
 
     int r = rpc_port_proxy_AutofillSvcPort_invoke_Register(h, auth_info_cb_h, fill_response_received_cb_h);
     if (r != 0)
@@ -599,6 +609,16 @@ static void __on_disconnected(rpc_port_proxy_AutofillSvcPort_h h, void *user_dat
     LOGD("disconnected");
 
     svc_rpc_h = NULL;
+
+    if (fill_response_received_cb_h) {
+        free(fill_response_received_cb_h);
+        fill_response_received_cb_h = NULL;
+    }
+
+    if (auth_info_cb_h) {
+        free(auth_info_cb_h);
+        auth_info_cb_h = NULL;
+    }
 }
 
 static void __on_rejected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data)