Merge "g_free 'field' and 'value' if you break out of a while loop." into tizen
[platform/core/connectivity/net-config.git] / src / wifi-eap-config.c
index 49283ba..48597c9 100755 (executable)
@@ -196,7 +196,7 @@ static gboolean __netconfig_copy_config(const char *src, const char *dst)
 
        result = g_file_get_contents(src, &buf, &length, &error);
        if (result != TRUE) {
-               ERR("Failed to read %s[%s]", error->message);
+               ERR("Failed to read [%s]", error->message);
                g_error_free(error);
 
                return result;
@@ -204,7 +204,7 @@ static gboolean __netconfig_copy_config(const char *src, const char *dst)
 
        result = g_file_set_contents(dst, buf, length, &error);
        if (result != TRUE) {
-               ERR("Failed to write %s[%s]", error->message);
+               ERR("Failed to write [%s]", error->message);
                g_error_free(error);
        }
 
@@ -287,6 +287,8 @@ static gboolean __netconfig_create_config(GVariant *fields)
                                cert_file = strrchr(value, '/');
                                if (cert_file == NULL) {
                                        ERR("Failed to get cert file: %s", value);
+                                       g_free(field);
+                                       g_free(value);
                                        goto out;
                                }
 
@@ -297,6 +299,8 @@ static gboolean __netconfig_create_config(GVariant *fields)
                                                WIFI_CERT_STORAGEDIR, encoded_ssid);
                                if (dirname == NULL) {
                                        ERR("Failed to create dirname");
+                                       g_free(field);
+                                       g_free(value);
                                        goto out;
                                }
                                if (g_file_test(dirname, G_FILE_TEST_IS_DIR) != TRUE) {
@@ -304,6 +308,8 @@ static gboolean __netconfig_create_config(GVariant *fields)
                                                        S_IXGRP | S_IROTH | S_IXOTH) < 0) {
                                                if (errno != EEXIST) {
                                                        g_free(dirname);
+                                                       g_free(field);
+                                                       g_free(value);
                                                        goto out;
                                                }
                                        }
@@ -314,11 +320,15 @@ static gboolean __netconfig_create_config(GVariant *fields)
                                                WIFI_CERT_STORAGEDIR, encoded_ssid, cert_file);
                                if (cert_path == NULL) {
                                        ERR("Failed to create cert path");
+                                       g_free(field);
+                                       g_free(value);
                                        goto out;
                                }
                                if (__netconfig_copy_config(value, cert_path) != TRUE) {
                                        ERR("Failed to read cert file %s", value);
                                        g_free(cert_path);
+                                       g_free(field);
+                                       g_free(value);
                                        goto out;
                                }
 
@@ -463,16 +473,15 @@ gboolean handle_create_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
                const gchar *service, GVariant *fields)
 {
        gboolean updated = FALSE;
-       gboolean reply = FALSE;
        gboolean result = FALSE;
 
-       g_return_val_if_fail(wifi != NULL, FALSE);
+       g_return_val_if_fail(wifi != NULL, TRUE);
 
        DBG("Set agent fields for %s", service);
 
        if (netconfig_is_wifi_profile(service) != TRUE) {
                netconfig_error_dbus_method_return(context, NETCONFIG_ERROR_WRONG_PROFILE, "InvalidService");
-               return reply;
+               return TRUE;
        }
 
        updated = __netconfig_create_config(fields);
@@ -524,20 +533,18 @@ gboolean handle_create_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
 
        if (result != TRUE)
                ERR("Fail to connect %s", service);
-       else
-               reply = TRUE;
 
-       return reply;
+       return TRUE;
 }
 
 gboolean handle_delete_eap_config(Wifi *wifi, GDBusMethodInvocation *context,
                const gchar *profile)
 {
-       g_return_val_if_fail(wifi != NULL, FALSE);
+       g_return_val_if_fail(wifi != NULL, TRUE);
 
        wifi_complete_delete_eap_config(wifi, context);
 
-       gboolean ret = __netconfig_delete_config((const char *)profile);
+       __netconfig_delete_config((const char *)profile);
 
-       return ret;
+       return TRUE;
 }