g_free 'field' and 'value' if you break out of a while loop. 66/194266/1
authorNiraj Kumar Goit <niraj.g@samsung.com>
Thu, 29 Nov 2018 13:50:30 +0000 (19:20 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Thu, 29 Nov 2018 13:50:30 +0000 (19:20 +0530)
g_free 'field' and 'value' if you break out of a while loop
using g_variant_iter_loop()

Change-Id: I4d76f723d9cedb3772a0f86db97152077cbfe7be
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
src/wifi-eap-config.c

index 66f67eb..d906d53 100755 (executable)
@@ -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;
                                }