Memory leak in gresources over libelf
When running the test with valgrind, a memory leak was detected in the form of libelf allocated memory
$ valgrind --tool=memcheck --leak-check=full ./gio/gresource list gio/tests/test.gresource
==96061== Memcheck, a memory error detector
==96061== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==96061== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==96061== Command: ./gio/gresource list gio/tests/test.gresource
==96061==
/a_prefix/test2-alias.txt
/a_prefix/test2.txt
/empty.txt
/test-generated.txt
/test.gresource.xml
/test1.txt
==96061==
==96061== HEAP SUMMARY:
==96061== in use at exit: 38,124 bytes in 261 blocks
==96061== total heap usage: 567 allocs, 306 frees, 72,775 bytes allocated
==96061==
==96061== 264 bytes in 1 blocks are definitely lost in loss record 234 of 240
==96061== at 0x48455EF: calloc (vg_replace_malloc.c:1328)
==96061== by 0x4C45340: ??? (in /usr/lib/x86_64-linux-gnu/libelf-0.188.so)
==96061== by 0x10A81E: get_elf (gresource-tool.c:158)
==96061== by 0x10AF8C: cmd_list (gresource-tool.c:417)
==96061== by 0x10C83E: main (gresource-tool.c:661)
==96061==
==96061== LEAK SUMMARY:
==96061== definitely lost: 264 bytes in 1 blocks
==96061== indirectly lost: 0 bytes in 0 blocks
==96061== possibly lost: 0 bytes in 0 blocks
==96061== still reachable: 35,844 bytes in 239 blocks
==96061== suppressed: 0 bytes in 0 blocks
==96061== Reachable blocks (those to which a pointer was found) are not shown.
==96061== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==96061==
==96061== For lists of detected and suppressed errors, rerun with: -s
==96061== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Leak started from get_elf over this if. Function returns NULL and (I think) memory should free before return.
Edited by Maxim Moskalets