Skip to content

Fix leak when copying command line string

Leak report

LSan report
Direct leak of 102 byte(s) in 1 object(s) allocated from:
    #0 0x5e48673c0769 in malloc (/usr/local/bin/xfce4-taskmanager+0x193769) (BuildId: 7b312ce28a4aeaa1)
    #1 0x7ac14dcaa5ba in g_malloc /usr/src/debug/glib2/build/../glib/glib/gmem.c:100:13
    #2 0x7ac14dcc06aa in g_strdup /usr/src/debug/glib2/build/../glib/glib/gstrfuncs.c:323:17
    #3 0x7ac14ddcdeec in g_strdup_inline /usr/src/debug/glib2/build/../glib/glib/gstrfuncs.h:321:10
    #4 0x7ac14ddcdeec in value_lcopy_string /usr/src/debug/glib2/build/../glib/gobject/gvaluetypes.c:315:17
    #5 0x7ac14e703b29 in gtk_tree_model_get_valist /usr/src/debug/gtk3/build/../gtk/gtk/gtktreemodel.c:1812:7
    #6 0x7ac14e703e61 in gtk_tree_model_get /usr/src/debug/gtk3/build/../gtk/gtk/gtktreemodel.c:1774:3
    #7 0x5e4867423c3f in cb_copy_command_line /home/s/code/xfce4-taskmanager/src/process-tree-view.c:532:4
    #8 0x7ac14dda7649 in g_closure_invoke /usr/src/debug/glib2/build/../glib/gobject/gclosure.c:834:7
    #9 0x7ac14ddd7ce4 in signal_emit_unlocked_R.isra.0 /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3888:8
    #10 0x7ac14ddc85db in signal_emit_valist_unlocked /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3520:7
    #11 0x7ac14ddc8841 in g_signal_emit_valist /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3263:7
    #12 0x7ac14ddc8903 in g_signal_emit /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3583:3
    #13 0x7ac14e7431ac in gtk_widget_activate /usr/src/debug/gtk3/build/../gtk/gtk/gtkwidget.c:7845:7
    #14 0x7ac14e5fc3fc in gtk_menu_shell_activate_item /usr/src/debug/gtk3/build/../gtk/gtk/gtkmenushell.c:1375:3
    #15 0x7ac14e5fc774 in gtk_menu_shell_button_release /usr/src/debug/gtk3/build/../gtk/gtk/gtkmenushell.c:791:19
    #16 0x7ac14e473969 in _gtk_marshal_BOOLEAN__BOXEDv /usr/src/debug/gtk3/build/gtk/gtkmarshalers.c:130:14
    #17 0x7ac14ddc8731 in _g_closure_invoke_va /usr/src/debug/glib2/build/../glib/gobject/gclosure.c:897:7
    #18 0x7ac14ddc8731 in signal_emit_valist_unlocked /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3424:8
    #19 0x7ac14ddc8841 in g_signal_emit_valist /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3263:7
    #20 0x7ac14ddc8903 in g_signal_emit /usr/src/debug/glib2/build/../glib/gobject/gsignal.c:3583:3
    #21 0x7ac14e757d14 in gtk_widget_event_internal.part.0.lto_priv.0 /usr/src/debug/gtk3/build/../gtk/gtk/gtkwidget.c:7812:4
    #22 0x7ac14e5e54b4 in propagate_event_up /usr/src/debug/gtk3/build/../gtk/gtk/gtkmain.c:2588:25
    #23 0x7ac14e5e54b4 in propagate_event /usr/src/debug/gtk3/build/../gtk/gtk/gtkmain.c:2691:5
    #24 0x7ac14e5e6272 in gtk_main_do_event /usr/src/debug/gtk3/build/../gtk/gtk/gtkmain.c:1921:9
    #25 0x7ac14e5e6272 in gtk_main_do_event /usr/src/debug/gtk3/build/../gtk/gtk/gtkmain.c:1691:1
    #26 0x7ac14e33b3c6 in _gdk_event_emit /usr/src/debug/gtk3/build/../gtk/gdk/gdkevents.c:73:6
    #27 0x7ac14e33b3c6 in _gdk_event_emit /usr/src/debug/gtk3/build/../gtk/gdk/gdkevents.c:67:1
    #28 0x7ac14e3971ff  /usr/src/debug/gtk3/build/../gtk/gdk/x11/gdkeventsource.c:354:1
    #29 0x7ac14dca4ab8 in g_main_dispatch /usr/src/debug/glib2/build/../glib/glib/gmain.c:3344:28
    #30 0x7ac14dd069e6 in g_main_context_dispatch_unlocked /usr/src/debug/glib2/build/../glib/glib/gmain.c:4152:7
    #31 0x7ac14dd069e6 in g_main_context_iterate_unlocked.isra.0 /usr/src/debug/glib2/build/../glib/glib/gmain.c:4217:5
    #32 0x7ac14dca57b6 in g_main_loop_run /usr/src/debug/glib2/build/../glib/glib/gmain.c:4419:5
    #33 0x7ac14e5e390e in gtk_main /usr/src/debug/gtk3/build/../gtk/gtk/gtkmain.c:1329:7

Testing

  • I verified that ASan and Valgrind don't report any memory errors when copying a command line string
  • I verified a copied command line string can be pasted from the clipboard

Build invocation

  • CFLAGS="-O1 -fsanitize=address -fno-omit-frame-pointer -fno-common" ./autogen.sh --prefix=/usr/local

Merge request reports

Loading