[Patch] Fix a bunch of leaks
Hey, Just as the subject says, fix about 10 memory leaks. Tambet Index: gnome/applet/applet.c === RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v retrieving revision 1.112.2.12 diff -u -r1.112.2.12 applet.c --- gnome/applet/applet.c 25 Oct 2006 03:39:20 - 1.112.2.12 +++ gnome/applet/applet.c 2 Nov 2006 15:23:09 - @@ -1764,12 +1764,14 @@ label = g_strdup_printf (_(Connect to %s...), name); connect_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (label)); + g_free (label); g_object_set_data (G_OBJECT (connect_item), dialup, name); g_signal_connect (G_OBJECT (connect_item), activate, G_CALLBACK (nma_menu_dialup_connect_item_activate), applet); gtk_menu_shell_append (GTK_MENU_SHELL (dialup_menu), GTK_WIDGET (connect_item)); label = g_strdup_printf (_(Disconnect from %s...), name); disconnect_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (label)); + g_free (label); g_object_set_data (G_OBJECT (disconnect_item), dialup, name); g_signal_connect (G_OBJECT (disconnect_item), activate, G_CALLBACK (nma_menu_dialup_disconnect_item_activate), applet); gtk_menu_shell_append (GTK_MENU_SHELL (dialup_menu), GTK_WIDGET (disconnect_item)); Index: gnome/applet/menu-items.c === RCS file: /cvs/gnome/NetworkManager/gnome/applet/menu-items.c,v retrieving revision 1.12.2.1 diff -u -r1.12.2.1 menu-items.c --- gnome/applet/menu-items.c 17 May 2006 20:03:56 - 1.12.2.1 +++ gnome/applet/menu-items.c 2 Nov 2006 15:23:09 - @@ -91,6 +91,7 @@ text = g_strdup (_(_Wired Network)); gtk_label_set_text_with_mnemonic (GTK_LABEL (item-label), text); + g_free (text); /* Only dim the item if the device supports carrier detection AND * we know it doesn't have a link. Index: src/nm-dbus-device.c === RCS file: /cvs/gnome/NetworkManager/src/nm-dbus-device.c,v retrieving revision 1.27.2.1 diff -u -r1.27.2.1 nm-dbus-device.c --- src/nm-dbus-device.c 21 Jun 2006 14:33:35 - 1.27.2.1 +++ src/nm-dbus-device.c 2 Nov 2006 15:23:09 - @@ -489,6 +489,8 @@ g_free (ip4_address); g_free (broadcast); g_free (subnetmask); + g_free (primary_dns); + g_free (secondary_dns); } return reply; Index: src/nm-device.c === RCS file: /cvs/gnome/NetworkManager/src/nm-device.c,v retrieving revision 1.17.2.7 diff -u -r1.17.2.7 nm-device.c --- src/nm-device.c 20 Sep 2006 15:35:12 - 1.17.2.7 +++ src/nm-device.c 2 Nov 2006 15:23:10 - @@ -85,14 +85,22 @@ discover_device_type (LibHalContext *ctx, const char *udi) { char * category = NULL; + NMDeviceType type = DEVICE_TYPE_UNKNOWN; if (libhal_device_property_exists (ctx, udi, info.category, NULL)) category = libhal_device_get_property_string(ctx, udi, info.category, NULL); - if (category (!strcmp (category, net.80211))) - return DEVICE_TYPE_802_11_WIRELESS; - else if (category (!strcmp (category, net.80203))) - return DEVICE_TYPE_802_3_ETHERNET; - return DEVICE_TYPE_UNKNOWN; + + if (category) + { + if (!strcmp (category, net.80211)) + type = DEVICE_TYPE_802_11_WIRELESS; + else if (!strcmp (category, net.80203)) + type = DEVICE_TYPE_802_3_ETHERNET; + + libhal_free_string (category); + } + + return type; } /* Index: src/backends/NetworkManagerSuSE.c === RCS file: /cvs/gnome/NetworkManager/src/backends/NetworkManagerSuSE.c,v retrieving revision 1.32.2.23 diff -u -r1.32.2.23 NetworkManagerSuSE.c --- src/backends/NetworkManagerSuSE.c 19 Oct 2006 20:39:54 - 1.32.2.23 +++ src/backends/NetworkManagerSuSE.c 2 Nov 2006 15:23:10 - @@ -808,6 +808,8 @@ if (sys_data-config) nm_ip4_config_unref (sys_data-config); + + g_free (sys_data); } Index: src/backends/shvar.c === RCS file: /cvs/gnome/NetworkManager/src/backends/shvar.c,v retrieving revision 1.2 diff -u -r1.2 shvar.c --- src/backends/shvar.c 6 May 2005 21:20:42 - 1.2 +++ src/backends/shvar.c 2 Nov 2006 15:23:10 - @@ -392,7 +392,12 @@ } g_free(s-fileName); g_list_free(s-freeList); -g_list_free(s-lineList); /* implicitly frees s-current */ + + if (s-lineList) { + g_list_foreach(s-lineList, (GFunc) g_free, NULL); + g_list_free(s-lineList); /* implicitly frees s-current */ + } + g_free(s); return 0; } ___ NetworkManager-list mailing list NetworkManager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: [Patch] Fix a bunch of leaks
Here's a diff that includes fixes to another couple of leaks. Tambet On Thu, 2006-11-02 at 17:23 +0200, Tambet Ingo wrote: Hey, Just as the subject says, fix about 10 memory leaks. Tambet ___ NetworkManager-list mailing list NetworkManager-list@gnome.org http://mail.gnome.org/mailman/listinfo/networkmanager-list Index: gnome/applet/applet.c === RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v retrieving revision 1.112.2.12 diff -u -r1.112.2.12 applet.c --- gnome/applet/applet.c 25 Oct 2006 03:39:20 - 1.112.2.12 +++ gnome/applet/applet.c 2 Nov 2006 16:01:10 - @@ -1764,12 +1764,14 @@ label = g_strdup_printf (_(Connect to %s...), name); connect_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (label)); + g_free (label); g_object_set_data (G_OBJECT (connect_item), dialup, name); g_signal_connect (G_OBJECT (connect_item), activate, G_CALLBACK (nma_menu_dialup_connect_item_activate), applet); gtk_menu_shell_append (GTK_MENU_SHELL (dialup_menu), GTK_WIDGET (connect_item)); label = g_strdup_printf (_(Disconnect from %s...), name); disconnect_item = GTK_MENU_ITEM (gtk_menu_item_new_with_label (label)); + g_free (label); g_object_set_data (G_OBJECT (disconnect_item), dialup, name); g_signal_connect (G_OBJECT (disconnect_item), activate, G_CALLBACK (nma_menu_dialup_disconnect_item_activate), applet); gtk_menu_shell_append (GTK_MENU_SHELL (dialup_menu), GTK_WIDGET (disconnect_item)); Index: gnome/applet/menu-items.c === RCS file: /cvs/gnome/NetworkManager/gnome/applet/menu-items.c,v retrieving revision 1.12.2.1 diff -u -r1.12.2.1 menu-items.c --- gnome/applet/menu-items.c 17 May 2006 20:03:56 - 1.12.2.1 +++ gnome/applet/menu-items.c 2 Nov 2006 16:01:10 - @@ -91,6 +91,7 @@ text = g_strdup (_(_Wired Network)); gtk_label_set_text_with_mnemonic (GTK_LABEL (item-label), text); + g_free (text); /* Only dim the item if the device supports carrier detection AND * we know it doesn't have a link. Index: src/NetworkManager.c === RCS file: /cvs/gnome/NetworkManager/src/NetworkManager.c,v retrieving revision 1.104.2.5 diff -u -r1.104.2.5 NetworkManager.c --- src/NetworkManager.c 20 Sep 2006 15:35:12 - 1.104.2.5 +++ src/NetworkManager.c 2 Nov 2006 16:01:10 - @@ -531,6 +531,11 @@ g_main_loop_unref (data-main_loop); g_main_context_unref (data-main_context); + nm_dbus_method_list_free (data-nm_methods); + nm_dbus_method_list_free (data-device_methods); + nm_dbus_method_list_free (data-net_methods); + nm_dbus_method_list_free (data-vpn_ethods); + g_io_channel_unref(data-sigterm_iochannel); nm_hal_deinit (data); Index: src/nm-dbus-device.c === RCS file: /cvs/gnome/NetworkManager/src/nm-dbus-device.c,v retrieving revision 1.27.2.1 diff -u -r1.27.2.1 nm-dbus-device.c --- src/nm-dbus-device.c 21 Jun 2006 14:33:35 - 1.27.2.1 +++ src/nm-dbus-device.c 2 Nov 2006 16:01:10 - @@ -489,6 +489,8 @@ g_free (ip4_address); g_free (broadcast); g_free (subnetmask); + g_free (primary_dns); + g_free (secondary_dns); } return reply; Index: src/nm-device.c === RCS file: /cvs/gnome/NetworkManager/src/nm-device.c,v retrieving revision 1.17.2.7 diff -u -r1.17.2.7 nm-device.c --- src/nm-device.c 20 Sep 2006 15:35:12 - 1.17.2.7 +++ src/nm-device.c 2 Nov 2006 16:01:11 - @@ -85,14 +85,22 @@ discover_device_type (LibHalContext *ctx, const char *udi) { char * category = NULL; + NMDeviceType type = DEVICE_TYPE_UNKNOWN; if (libhal_device_property_exists (ctx, udi, info.category, NULL)) category = libhal_device_get_property_string(ctx, udi, info.category, NULL); - if (category (!strcmp (category, net.80211))) - return DEVICE_TYPE_802_11_WIRELESS; - else if (category (!strcmp (category, net.80203))) - return DEVICE_TYPE_802_3_ETHERNET; - return DEVICE_TYPE_UNKNOWN; + + if (category) + { + if (!strcmp (category, net.80211)) + type = DEVICE_TYPE_802_11_WIRELESS; + else if (!strcmp (category, net.80203)) + type = DEVICE_TYPE_802_3_ETHERNET; + + libhal_free_string (category); + } + + return type; } /* Index: src/backends/NetworkManagerSuSE.c === RCS file: /cvs/gnome/NetworkManager/src/backends/NetworkManagerSuSE.c,v retrieving revision 1.32.2.23 diff -u -r1.32.2.23 NetworkManagerSuSE.c --- src/backends/NetworkManagerSuSE.c 19 Oct 2006 20:39:54 - 1.32.2.23 +++ src/backends/NetworkManagerSuSE.c 2 Nov 2006 16:01:11 - @@ -808,6 +808,8 @@ if (sys_data-config) nm_ip4_config_unref (sys_data-config); + + g_free (sys_data); } Index: src/backends/shvar.c