From: Seonah Moon Date: Mon, 13 Feb 2017 08:28:47 +0000 (+0900) Subject: WGID-9093: Fixed memory leak X-Git-Tag: submit/tizen/20170213.093416^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7841e5506f14788c3e7bde07b169aa4ba5cc8d50;p=platform%2Fcore%2Fapi%2Fwifi.git WGID-9093: Fixed memory leak Change-Id: I2bc4eea631037be347a5ed687c735f7168740822 Signed-off-by: Seonah Moon --- diff --git a/src/net_wifi_config.c b/src/net_wifi_config.c index 20c80c4..c762e1b 100755 --- a/src/net_wifi_config.c +++ b/src/net_wifi_config.c @@ -277,7 +277,7 @@ EXPORT_API int wifi_config_foreach_configuration(wifi_config_list_cb callback, v } while (config_ids) { - bool rv = 0; + bool rv = 1; struct _wifi_config *h; gchar *id = config_ids->data; @@ -291,6 +291,7 @@ EXPORT_API int wifi_config_foreach_configuration(wifi_config_list_cb callback, v h->eap_config = g_new0(struct _wifi_eap_config, 1); if (h->eap_config == NULL) { ret = WIFI_ERROR_OUT_OF_MEMORY; + g_free(h); break; } ret = wifi_load_eap_configurations(dbus_h, id, &h->name, @@ -306,23 +307,24 @@ EXPORT_API int wifi_config_foreach_configuration(wifi_config_list_cb callback, v h->address_family = WIFI_ADDRESS_FAMILY_IPV4; h->is_saved = TRUE; rv = callback((wifi_config_h)h, user_data); - g_free(h->name); - g_free(h->proxy_address); - if (h->eap_config) { - g_free(h->eap_config->ca_cert); - g_free(h->eap_config->client_cert); - g_free(h->eap_config->private_key); - g_free(h->eap_config->anonymous_identity); - g_free(h->eap_config->identity); - g_free(h->eap_config->subject_match); - g_free(h->eap_config); - } - g_free(h); - h = NULL; + } - if (rv == false) - break; + g_free(h->name); + g_free(h->proxy_address); + if (h->eap_config) { + g_free(h->eap_config->ca_cert); + g_free(h->eap_config->client_cert); + g_free(h->eap_config->private_key); + g_free(h->eap_config->anonymous_identity); + g_free(h->eap_config->identity); + g_free(h->eap_config->subject_match); + g_free(h->eap_config); } + g_free(h); + h = NULL; + + if (rv == false) + break; config_ids = config_ids->next; }