summaryrefslogtreecommitdiff
path: root/gtk/gtktestutils.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-09-26 18:00:19 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-09-26 18:00:19 -0400
commit8e1878bc320cecffedaa8747db18ca042461002e (patch)
tree79c9dab2ad856e541559a4ca7b18a1e02b5e348a /gtk/gtktestutils.c
parent5744bb3cf16cabfe4ee4677c7250ee8f90550a37 (diff)
downloadgtk+-8e1878bc320cecffedaa8747db18ca042461002e.tar.gz
Fix a memory leak in gtk_test_find_label
Pointed out by Garrett Regier in https://bugzilla.gnome.org/show_bug.cgi?id=737439
Diffstat (limited to 'gtk/gtktestutils.c')
-rw-r--r--gtk/gtktestutils.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/gtk/gtktestutils.c b/gtk/gtktestutils.c
index b96a828f1b..a024614220 100644
--- a/gtk/gtktestutils.c
+++ b/gtk/gtktestutils.c
@@ -291,24 +291,29 @@ GtkWidget*
gtk_test_find_label (GtkWidget *widget,
const gchar *label_pattern)
{
+ GtkWidget *label = NULL;
+
if (GTK_IS_LABEL (widget))
{
const gchar *text = gtk_label_get_text (GTK_LABEL (widget));
if (g_pattern_match_simple (label_pattern, text))
return widget;
}
+
if (GTK_IS_CONTAINER (widget))
{
- GList *node, *list = gtk_container_get_children (GTK_CONTAINER (widget));
+ GList *node, *list;
+
+ list = gtk_container_get_children (GTK_CONTAINER (widget));
for (node = list; node; node = node->next)
{
- GtkWidget *label = gtk_test_find_label (node->data, label_pattern);
+ label = gtk_test_find_label (node->data, label_pattern);
if (label)
- return label;
+ break;
}
g_list_free (list);
}
- return NULL;
+ return label;
}
static GList*