Fix for CID:860243 07/183507/2
authorAbhishek Sansanwal <abhishek.s94@samsung.com>
Fri, 6 Jul 2018 05:53:19 +0000 (11:23 +0530)
committerAbhishek Sansanwal <abhishek.s94@samsung.com>
Thu, 6 Jul 2017 07:05:28 +0000 (12:35 +0530)
Description: Free resource using g_free
before returning from the function.

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

gtest/vpn.cpp

index b0c56a7..ec42fba 100755 (executable)
@@ -122,12 +122,14 @@ error_e Vpnsvc::vpn_protect(const char *dev_name, 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;
        }
 
@@ -142,12 +144,14 @@ error_e Vpnsvc::vpn_protect(const char *dev_name, 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, "(i)", result);
        g_variant_unref(message);
        close(iface_fd);
+       g_object_unref(fd_list);
 
        return ERROR_NONE;
 }