[gtk+] dialog: Avoid a memory leak in an error case
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] dialog: Avoid a memory leak in an error case
- Date: Fri, 26 Feb 2016 20:52:54 +0000 (UTC)
commit 5ca860dcaf0b636b50fe54cd2abff7e92091bdb3
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Feb 26 14:50:25 2016 -0500
dialog: Avoid a memory leak in an error case
Parsing <action-widgets> could sometimes fail to free
some of the data, if a nonexisting widget is referenced.
Found by gcc's leak sanitizer.
gtk/gtkdialog.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index ad1828a..45dc5be 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -1688,6 +1688,15 @@ typedef struct {
} SubParserData;
static void
+free_action_widget_info (gpointer data)
+{
+ ActionWidgetInfo *item = data;
+
+ g_free (item->widget_name);
+ g_free (item);
+}
+
+static void
parser_start_element (GMarkupParseContext *context,
const gchar *element_name,
const gchar **names,
@@ -1894,12 +1903,9 @@ gtk_dialog_buildable_custom_finished (GtkBuildable *buildable,
if (item->is_default)
gtk_widget_grab_default (GTK_WIDGET (object));
-
- g_free (item->widget_name);
- g_free (item);
}
- g_slist_free (data->items);
+ g_slist_free_full (data->items, free_action_widget_info);
g_string_free (data->string, TRUE);
g_slice_free (SubParserData, data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]