Don't free dbus method invocation twice 32/185032/2
authorSaurav Babu <saurav.babu@samsung.com>
Wed, 25 Jul 2018 09:24:48 +0000 (14:54 +0530)
committerSaurav Babu <saurav.babu@samsung.com>
Thu, 26 Jul 2018 04:01:49 +0000 (09:31 +0530)
Change-Id: I6b006b5c547d809acd6c4126da35cc3d80869585
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
src/wifi-agent.c

index b8926d2..e66ffa4 100755 (executable)
@@ -299,13 +299,13 @@ gboolean handle_set_field(NetConnmanAgent *connman_agent,
                }
        }
 
+       g_variant_iter_free(iter);
+
        if (updated == TRUE) {
                reply = netconfig_invoke_dbus_method_nonblock(CONNMAN_SERVICE,
                                service, CONNMAN_SERVICE_INTERFACE, "Connect",
                                NULL, __netconfig_wifi_connect_reply);
-               if (reply == TRUE) {
-                       g_dbus_method_invocation_return_value(context, NULL);
-               } else {
+               if (reply != TRUE) {
                        ERR("Fail to connect Wi-Fi");
                        __netconfig_agent_clear_fields();
                        error = g_error_new(G_DBUS_ERROR,
@@ -314,22 +314,21 @@ gboolean handle_set_field(NetConnmanAgent *connman_agent,
 
                        g_dbus_method_invocation_return_gerror(context, error);
                        g_clear_error(&error);
+                       return TRUE;
                }
        } else {
+               ERR("Fail to connect Wi-Fi");
+               __netconfig_agent_clear_fields();
+
                error = g_error_new(G_DBUS_ERROR,
                                G_DBUS_ERROR_AUTH_FAILED,
                                CONNMAN_ERROR_INTERFACE ".InvalidArguments");
 
                g_dbus_method_invocation_return_gerror(context, error);
                g_clear_error(&error);
+               return TRUE;
        }
 
-       if (reply != TRUE) {
-               ERR("Fail to connect Wi-Fi");
-               __netconfig_agent_clear_fields();
-       }
-       g_variant_iter_free(iter);
-
        net_connman_agent_complete_set_field(connman_agent, context);
        return TRUE;
 }