Fix for CID:860282 05/183505/2
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Fri, 6 Jul 2018 05:46:35 +0000 (11:16 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Fri, 6 Jul 2018 06:09:51 +0000 (11:39 +0530)
Description: Call g_free on resource before return.

Signed-off-by: Abhishek Sansanwal <abhishek.s94@samsung.com>
Change-Id: I66412afbec1ad04e5e16a2edfe96f913ee1ceb1d

gtest/vpn.cpp

index b0c56a7..9ad6917 100755 (executable)
@@ -53,12 +53,14 @@ error_e Vpnsvc::vpn_init(const char *iface_name, int iface_name_len, int *result
 
        if ((iface_fd = open("/dev/net/tun", O_RDWR)) < 0) {
                GLOGD("tun device open fail\n");
+               g_object_unref(fd_list);
                return ERROR_OPERATION_FAILED;
        }
 
        g_unix_fd_list_append(fd_list, iface_fd, &g_error);
        if (g_error != NULL) {
                close(iface_fd);
+               g_object_unref(fd_list);
                return ERROR_OPERATION_FAILED;
        }
 
@@ -73,12 +75,14 @@ error_e Vpnsvc::vpn_init(const char *iface_name, int iface_name_len, int *result
        if (message == NULL) {
                GLOGD("Failed to invoke dbus method");
                close(iface_fd);
+               g_object_unref(fd_list);
                return error;
        }
 
        g_variant_get(message, "(iis)", result, h_index, h_name);
        g_variant_unref(message);
        close(iface_fd);
+       g_object_unref(fd_list);
 
        return ERROR_NONE;
 }