Fix memory leak issue 71/201571/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Mon, 18 Mar 2019 01:20:13 +0000 (10:20 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 18 Mar 2019 01:26:46 +0000 (10:26 +0900)
Dynamic memory referenced by 'handle->auth_info_cb' was allocated at autofill_service_stub.c:4040 by calling function 'rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_clone' at autofill_service.c:288 and lost at autofill_service.c:311.
Dynamic memory referenced by 'handle->fill_response_received_cb' was allocated at autofill_service_stub.c:4188 by calling function 'rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_clone' at autofill_service.c:296 and lost at autofill_service.c:311.

Change-Id: Iede991ba41e6fd24de1297dadd1335f8e6a97977
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
service_lib/autofill_service.c

index 8113909..c8631bc 100644 (file)
@@ -307,6 +307,8 @@ static autofill_svc_s *__create_client(const char *app_id,
     if (!handle->send_error_cb) {
         LOGE("Out of memory");
         free(handle->app_id);
+        rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(handle->auth_info_cb);
+        rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_destroy(handle->fill_response_received_cb);
         free(handle);
         return NULL;
     }
@@ -322,17 +324,25 @@ static void __destroy_client(gpointer data)
     if (!handle)
         return;
 
-    if (handle->auth_info_cb)
+    if (handle->auth_info_cb) {
         rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(handle->auth_info_cb);
+        handle->auth_info_cb = NULL;
+    }
 
-    if (handle->fill_response_received_cb)
+    if (handle->fill_response_received_cb) {
         rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_destroy(handle->fill_response_received_cb);
+        handle->fill_response_received_cb = NULL;
+    }
 
-    if (handle->send_error_cb)
+    if (handle->send_error_cb) {
         rpc_port_AutofillSvcPort_autofill_svc_send_error_cb_destroy(handle->send_error_cb);
+        handle->send_error_cb = NULL;
+    }
 
-    if (handle->app_id)
+    if (handle->app_id) {
         free(handle->app_id);
+        handle->app_id = NULL;
+    }
 
     free(handle);
 }