Memory leak in thunar_gtk_label_set_a11y_relation
Version information
ffe968d4 on Arch Linux
Steps to reproduce
- Run Thunar
- Select
Edit > Preferences
to trigger the leak
Current behavior
Leak report
LSan output
Direct leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x579e09b2dde9 in calloc (/usr/local/bin/thunar+0x457de9) (BuildId: 7527e34e3d860c35)
#1 0x74089b146b62 in g_malloc0 /usr/src/debug/glib2/build/../glib/glib/gmem.c:133:13
#2 0x74089bc747b5 in g_type_create_instance /usr/src/debug/glib2/build/../glib/gobject/gtype.c:1933:17
#3 0x74089bc59684 in g_object_new_internal /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2606:24
#4 0x74089bc5acfe in g_object_new_internal /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2603:6
#5 0x74089bc5acfe in g_object_new_with_properties /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2769:14
#6 0x74089bc5bd51 in g_object_new /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2415:12
#7 0x74089c236f6c in atk_object_init /usr/src/debug/at-spi2-core/build/../at-spi2-core/atk/atkobject.c:659:30
#8 0x74089bc7480a in g_type_create_instance /usr/src/debug/glib2/build/../glib/gobject/gtype.c:1945:4
#9 0x74089bc59684 in g_object_new_internal /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2606:24
#10 0x74089bc5b97a in g_object_new_internal /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2923:29
#11 0x74089bc5b97a in g_object_new_valist /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2945:16
#12 0x74089bc5bd2f in g_object_new /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2418:12
#13 0x74089b755372 in gtk_widget_real_get_accessible /usr/src/debug/gtk3/build/../gtk/gtk/gtkwidget.c:13563:24
#14 0x74089b755372 in gtk_widget_real_get_accessible /usr/src/debug/gtk3/build/../gtk/gtk/gtkwidget.c:13533:1
#15 0x579e09c59c04 in thunar_gtk_label_set_a11y_relation thunar/thunar/thunar-gtk-extensions.c:61:44
#16 0x579e09cc4aef in thunar_preferences_dialog_init thunar/thunar/thunar-preferences-dialog.c:839:3
#17 0x74089bc74848 in g_type_create_instance /usr/src/debug/glib2/build/../glib/gobject/gtype.c:1951:5
#18 0x74089bc595ea in g_object_constructor /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2981:23
#19 0x74089bc59093 in g_object_new_with_custom_constructor /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2524:12
#20 0x74089bc5acab in g_object_new_internal /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2604:12
#21 0x74089bc5acab in g_object_new_with_properties /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2769:14
#22 0x74089bc5bd51 in g_object_new /usr/src/debug/glib2/build/../glib/gobject/gobject.c:2415:12
#23 0x579e09cc2768 in thunar_preferences_dialog_new thunar/thunar/thunar-preferences-dialog.c:1518:12
#24 0x579e09df2794 in thunar_window_action_preferences thunar/thunar/thunar-window.c:3777:12
#25 0x74089bc47699 in g_closure_invoke /usr/src/debug/glib2/build/../glib/gobject/gclosure.c:834:7
#26 0x74089bc782a4 in signal_emit_unlocked_R.isra.0 /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3888:8
#27 0x74089bc68a0b in signal_emit_valist_unlocked /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3520:7
#28 0x74089bc68c71 in g_signal_emit_valist /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3263:7
#29 0x74089bc68d33 in g_signal_emit /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3583:3
#30 0x74089b745abc in gtk_widget_activate /usr/src/debug/gtk3/build/../gtk/gtk/gtkwidget.c:7845:7
#31 0x74089b5fdacc in gtk_menu_shell_activate_item /usr/src/debug/gtk3/build/../gtk/gtk/gtkmenushell.c:1375:3
Expected outcome
No leak
Additional information
The following patch seems to prevent the leak, but I'm not very familiar with Atk code or the thunar_gtk_label_set_a11y_relation function:
diff --git a/thunar/thunar-gtk-extensions.c b/thunar/thunar-gtk-extensions.c
index aba550465..559037027 100644
--- a/thunar/thunar-gtk-extensions.c
+++ b/thunar/thunar-gtk-extensions.c
@@ -62,6 +62,7 @@ thunar_gtk_label_set_a11y_relation (GtkLabel *label,
relation = atk_relation_new (&object, 1, ATK_RELATION_LABEL_FOR);
atk_relation_set_add (relations, relation);
g_object_unref (G_OBJECT (relation));
+ g_object_unref (relations);
}