Skip to content
  • Roman Lebedev's avatar
    glib-compile-resources: do not leak c_name · 4cda92b5
    Roman Lebedev authored and Matthias Clasen's avatar Matthias Clasen committed
    As per #578363, "if one requests e.g. strings via GOptionEntry.arg_data
    then those are strduped and needs to be free'ed by the application."
    
    Fixes following leak:
    
    =================================================================
    ==29426==ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 10 byte(s) in 1 object(s) allocated from:
        0 0x7f3ab783d37a in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x9437a)
        1 0x7f3ab70f7c82 in g_malloc /home/lebedevri/src/glib/glib/gmem.c:94
        2 0x7f3ab70f7f60 in g_malloc_n /home/lebedevri/src/glib/glib/gmem.c:330
        3 0x7f3ab713258e in g_strndup /home/lebedevri/src/glib/glib/gstrfuncs.c:425
        4 0x7f3ab709c86b in strdup_len /home/lebedevri/src/glib/glib/gconvert.c:864
        5 0x7f3ab709c966 in g_locale_to_utf8 /home/lebedevri/src/glib/glib/gconvert.c:905
        6 0x7f3ab7103c32 in parse_arg /home/lebedevri/src/glib/glib/goption.c:1276
        7 0x7f3ab71066fb in parse_long_option /home/lebedevri/src/glib/glib/goption.c:1670
        8 0x7f3ab7108047 in g_option_context_parse /home/lebedevri/src/glib/glib/goption.c:1997
        9 0x408532 in main /home/lebedevri/src/glib/gio/glib-compile-resources.c:629
        10 0x7f3ab6c72b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=757299
    4cda92b5