Fix resurce leak problem (Prevent) 80/164580/2
authorsaerome.kim <saerome.kim@samsung.com>
Wed, 20 Dec 2017 00:36:31 +0000 (09:36 +0900)
committersaerome kim <saerome.kim@samsung.com>
Wed, 20 Dec 2017 00:53:13 +0000 (00:53 +0000)
- CID 72897

Change-Id: I8b67801d3b04e03179cc6c26eda892a656dc4aa4
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
src/wmesh-gdbus.c

index c22d51e..214d8ee 100755 (executable)
@@ -1092,18 +1092,21 @@ int wmesh_gdbus_create_network(wmesh_service *service, gchar *mesh_id,
 
 int wmesh_gdbus_set_passphrase(wmesh_service *service, wmesh_scan_result_s *info, gchar *passphrase)
 {
+       int ret = WMESHD_ERROR_NONE;
        GVariant *variant = NULL;
+       GVariant *var_passphrase = NULL;
        GError *error = NULL;
 
        wmeshd_check_null_ret_error("service", service, WMESHD_ERROR_INVALID_PARAMETER);
        wmeshd_check_null_ret_error("passphrase", passphrase, WMESHD_ERROR_INVALID_PARAMETER);
 
+       var_passphrase = g_variant_new_string(passphrase);
        variant = g_dbus_connection_call_sync(service->connection,
                        CONNMAN_SERVER_NAME,
                        info->object_path,
                        CONNMAN_INTERFACE_MESH,
                        "SetProperty",
-                       g_variant_new("(sv)", "Passphrase", g_variant_new_string(passphrase)),
+                       g_variant_new("(sv)", "Passphrase", var_passphrase),
                        NULL,
                        G_DBUS_CALL_FLAGS_NONE,
                        -1, NULL, &error);
@@ -1112,10 +1115,10 @@ int wmesh_gdbus_set_passphrase(wmesh_service *service, wmesh_scan_result_s *info
        } else if (error) {
                WMESH_LOGE("Failed DBus call [%s]", error->message);
                g_error_free(error);
-               return WMESHD_ERROR_IO_ERROR;
+               ret = WMESHD_ERROR_IO_ERROR;
        }
-
-       return WMESHD_ERROR_NONE;
+       g_variant_unref(var_passphrase);
+       return ret;
 }
 
 #if 0