Fix memory leaks in gsupplicant interface_property
authorLeena Gunda <leena.gunda@wipro.com>
Thu, 6 Jan 2011 06:27:33 +0000 (11:57 +0530)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 6 Jan 2011 07:33:00 +0000 (23:33 -0800)
Free the interface properties before doing a g_strdup.

Fixes BMC#11687

gsupplicant/supplicant.c

index 6302af0..95e5efc 100644 (file)
@@ -1272,20 +1272,26 @@ static void interface_property(const char *key, DBusMessageIter *iter,
                const char *str = NULL;
 
                dbus_message_iter_get_basic(iter, &str);
-               if (str != NULL)
+               if (str != NULL) {
+                       g_free(interface->ifname);
                        interface->ifname = g_strdup(str);
+               }
        } else if (g_strcmp0(key, "Driver") == 0) {
                const char *str = NULL;
 
                dbus_message_iter_get_basic(iter, &str);
-               if (str != NULL)
+               if (str != NULL) {
+                       g_free(interface->driver);
                        interface->driver = g_strdup(str);
+               }
        } else if (g_strcmp0(key, "BridgeIfname") == 0) {
                const char *str = NULL;
 
                dbus_message_iter_get_basic(iter, &str);
-               if (str != NULL)
+               if (str != NULL) {
+                       g_free(interface->bridge);
                        interface->bridge = g_strdup(str);
+               }
        } else if (g_strcmp0(key, "CurrentBSS") == 0) {
                interface_bss_added(iter, interface);
        } else if (g_strcmp0(key, "CurrentNetwork") == 0) {