Skip to content

Plug leak stemming from g_path_get_basename

correctmost requested to merge correctmost/xfce4-dev-tools:cm/fix-leak into master

This MR fixes an error when building with AddressSanitizer + LeakSanitizer:

Making all in xdt-csource
make[1]: Entering directory '/home/s/code/xfce4-dev-tools/xdt-csource'
  CC       xdt_csource-main.o
  CCLD     xdt-csource
make[1]: Leaving directory '/home/s/code/xfce4-dev-tools/xdt-csource'
Making all in tests
make[1]: Entering directory '/home/s/code/xfce4-dev-tools/tests'
../xdt-csource/xdt-csource --extern --build-list data_bin ./data/data.bin data_txt ./data/data.txt > test-xdt-csource-data.c

=================================================================
==4162==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x5831dd56e279 in malloc (/home/s/code/xfce4-dev-tools/xdt-csource/xdt-csource+0x15c279) (BuildId: 9821e4bcb168934e)
    #1 0x778ef55595ba in g_malloc (/usr/lib/libglib-2.0.so.0+0x625ba) (BuildId: 7abffba39dc59aa95290cbeb721e69fe4e3012fb)
    #2 0x778ef55384b7 in g_path_get_basename (/usr/lib/libglib-2.0.so.0+0x414b7) (BuildId: 7abffba39dc59aa95290cbeb721e69fe4e3012fb)
    #3 0x5831dd5b6d4a in main /home/s/code/xfce4-dev-tools/xdt-csource/main.c:355:18
    #4 0x778ef5206c87  (/usr/lib/libc.so.6+0x25c87) (BuildId: 32a656aa5562eece8c59a585f5eacd6cf5e2307b)
    #5 0x778ef5206d4b in __libc_start_main (/usr/lib/libc.so.6+0x25d4b) (BuildId: 32a656aa5562eece8c59a585f5eacd6cf5e2307b)
    #6 0x5831dd482194 in _start (/home/s/code/xfce4-dev-tools/xdt-csource/xdt-csource+0x70194) (BuildId: 9821e4bcb168934e)

SUMMARY: AddressSanitizer: 12 byte(s) leaked in 1 allocation(s).
make[1]: *** [Makefile:1157: test-xdt-csource-data.c] Error 1
make[1]: Leaving directory '/home/s/code/xfce4-dev-tools/tests'
make: *** [Makefile:409: all-recursive] Error 1

Merge request reports

Loading