From d841102ab7333e85ae24364df1b895cf85aa0605 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Wed, 25 May 2016 13:49:22 +0900 Subject: [PATCH] Fixed memory leaks LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks indirectly lost: 0 bytes in 0 blocks possibly lost: 8,780 bytes in 285 blocks still reachable: 93,570 bytes in 1,750 blocks suppressed: 0 bytes in 0 blocks Change-Id: Ieb6fd5ec2909f2ea71207dfd80714cd677203540 Signed-off-by: hyunuktak --- packaging/net-config.spec | 2 +- src/network-state.c | 8 ++++++++ src/signal-handler.c | 39 +++++++++++++++++++++++++++++++-------- src/utils/util.c | 0 src/wifi-agent.c | 1 + src/wifi-state.c | 1 + 6 files changed, 42 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/network-state.c mode change 100644 => 100755 src/utils/util.c diff --git a/packaging/net-config.spec b/packaging/net-config.spec index 36965c8..69f083e 100755 --- a/packaging/net-config.spec +++ b/packaging/net-config.spec @@ -1,6 +1,6 @@ Name: net-config Summary: TIZEN Network Configuration service -Version: 1.1.69 +Version: 1.1.70 Release: 2 Group: System/Network License: Apache-2.0 diff --git a/src/network-state.c b/src/network-state.c old mode 100644 new mode 100755 index cfba8d9..7df844c --- a/src/network-state.c +++ b/src/network-state.c @@ -196,6 +196,8 @@ static void __netconfig_get_default_connection_info(const char *profile) netconfig_default_connection_info.ifname = g_strdup(value); } } + if (iter1) + g_variant_iter_free(iter1); } else if (g_strcmp0(key, "IPv4") == 0) { g_variant_get(next, "a{sv}", &iter1); while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) { @@ -204,6 +206,8 @@ static void __netconfig_get_default_connection_info(const char *profile) netconfig_default_connection_info.ipaddress = g_strdup(value); } } + if (iter1) + g_variant_iter_free(iter1); } else if (g_strcmp0(key, "IPv6") == 0) { g_variant_get(next, "a{sv}", &iter1); while (g_variant_iter_loop(iter1, "{sv}", &key1, &variant)) { @@ -212,6 +216,8 @@ static void __netconfig_get_default_connection_info(const char *profile) netconfig_default_connection_info.ipaddress6 = g_strdup(value); } } + if (iter1) + g_variant_iter_free(iter1); } else if (g_strcmp0(key, "Proxy") == 0) { g_variant_get(next, "a{sv}", &iter1); while (g_variant_iter_loop(iter1, "{sv}", &key2, &variant2)) { @@ -247,6 +253,8 @@ static void __netconfig_get_default_connection_info(const char *profile) } } } + if (iter1) + g_variant_iter_free(iter1); } else if (g_strcmp0(key, "Frequency") == 0) { if (g_variant_is_of_type(next, G_VARIANT_TYPE_UINT16)) { freq = g_variant_get_uint16(next); diff --git a/src/signal-handler.c b/src/signal-handler.c index 94703ce..02bdde8 100755 --- a/src/signal-handler.c +++ b/src/signal-handler.c @@ -162,12 +162,16 @@ static void _service_signal_cb(GDBusConnection *conn, int wifi_state = 0; vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state); - if (wifi_state == VCONFKEY_WIFI_OFF) + if (wifi_state == VCONFKEY_WIFI_OFF) { + g_free(property); goto done; + } if (g_strcmp0(property, "ready") == 0 || g_strcmp0(property, "online") == 0) { - if (wifi_state >= VCONFKEY_WIFI_CONNECTED) + if (wifi_state >= VCONFKEY_WIFI_CONNECTED) { + g_free(property); goto done; + } netconfig_update_default_profile(path); @@ -181,11 +185,14 @@ static void _service_signal_cb(GDBusConnection *conn, wifi_state_set_service_state(NETCONFIG_WIFI_FAILURE); else wifi_state_set_service_state(NETCONFIG_WIFI_IDLE); + g_free(property); goto done; } - if (g_strcmp0(path, netconfig_get_default_profile()) != 0) + if (g_strcmp0(path, netconfig_get_default_profile()) != 0) { + g_free(property); goto done; + } netconfig_update_default_profile(NULL); @@ -201,11 +208,14 @@ static void _service_signal_cb(GDBusConnection *conn, wifi_state_set_service_state(NETCONFIG_WIFI_ASSOCIATION); else wifi_state_set_service_state(NETCONFIG_WIFI_CONFIGURATION); + g_free(property); goto done; } - if (g_strcmp0(path, netconfig_get_default_profile()) != 0) + if (g_strcmp0(path, netconfig_get_default_profile()) != 0) { + g_free(property); goto done; + } netconfig_update_default_profile(NULL); @@ -230,29 +240,38 @@ static void _service_signal_cb(GDBusConnection *conn, cellular_state_set_service_state(NETCONFIG_CELLULAR_ONLINE); } else if (g_strcmp0(property, "failure") == 0 || g_strcmp0(property, "disconnect") == 0 || g_strcmp0(property, "idle") == 0) { - if (netconfig_get_default_profile() == NULL) + if (netconfig_get_default_profile() == NULL) { + g_free(property); goto done; + } if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path)) cellular_state_set_service_state(NETCONFIG_CELLULAR_IDLE); - if (g_strcmp0(path, netconfig_get_default_profile()) != 0) + if (g_strcmp0(path, netconfig_get_default_profile()) != 0) { + g_free(property); goto done; + } netconfig_update_default_profile(NULL); } else if (g_strcmp0(property, "association") == 0 || g_strcmp0(property, "configuration") == 0) { - if (netconfig_get_default_profile() == NULL) + if (netconfig_get_default_profile() == NULL) { + g_free(property); goto done; + } if (netconfig_is_cellular_profile(path) && netconfig_is_cellular_internet_profile(path)) cellular_state_set_service_state(NETCONFIG_CELLULAR_CONNECTING); - if (g_strcmp0(path, netconfig_get_default_profile()) != 0) + if (g_strcmp0(path, netconfig_get_default_profile()) != 0) { + g_free(property); goto done; + } netconfig_update_default_profile(NULL); } } + g_free(property); } else if (g_strcmp0(sigvalue, "Proxy") == 0) { if (netconfig_is_wifi_profile(path) != TRUE || g_strcmp0(path, netconfig_get_default_profile()) != 0) goto done; @@ -292,6 +311,7 @@ static void _service_signal_cb(GDBusConnection *conn, } else if (g_strcmp0(sigvalue, "Error") == 0) { g_variant_get(variant, "s", &property); INFO("[%s] Property : %s", sigvalue, property); + g_free(property); } done: if (sigvalue) @@ -368,6 +388,7 @@ static void _services_changed_cb(GDBusConnection *conn, const gchar *name, g_strcmp0(value, "online") != 0) { g_free(property); + g_free(value); g_variant_unref(variant); break; } @@ -387,6 +408,7 @@ static void _services_changed_cb(GDBusConnection *conn, const gchar *name, cellular_state_set_service_state( NETCONFIG_CELLULAR_ONLINE); g_free(property); + g_free(value); g_variant_unref(variant); break; } @@ -398,6 +420,7 @@ static void _services_changed_cb(GDBusConnection *conn, const gchar *name, if (next) g_variant_iter_free(next); + if (removed) g_variant_iter_free(removed); diff --git a/src/utils/util.c b/src/utils/util.c old mode 100644 new mode 100755 diff --git a/src/wifi-agent.c b/src/wifi-agent.c index 3c7c87b..9e12fff 100755 --- a/src/wifi-agent.c +++ b/src/wifi-agent.c @@ -105,6 +105,7 @@ int connman_register_agent(void) if (error != NULL) { if (g_strcmp0(error->message, "GDBus.Error:net.connman.Error.AlreadyExists: Already exists") == 0) { + g_error_free(error); break; } else { ERR("Fail to register agent [%d: %s]", diff --git a/src/wifi-state.c b/src/wifi-state.c index adf918b..3b34ca4 100755 --- a/src/wifi-state.c +++ b/src/wifi-state.c @@ -344,6 +344,7 @@ static void _set_power_save(gboolean power_save) else old_state = power_save; + g_variant_unref(input_args); return; } -- 2.7.4