xdg: plug memory leak; saved_action_name is already strdup:ed once
Before adoption: this commit came in with the history the project adopted, so no landing records it.
We always strdup() saved_action_name. strdup():ing it again when filling out the application entry leads to a memory leak: $ valgrind --leak-check=full ./fuzzel ==18079== Memcheck, a memory error detector ==18079== Copyright (C) 2002-2024, and GNU GPL'd, by Julian Seward et al. ==18079== Using Valgrind-3.25.1 and LibVEX; rerun with -h for copyright info ==18079== Command: ./fuzzel ==18079== warn: wayland.c:2946: gamma-correct-blending: disabling; not supported in cairo-enabled builds ==18079== ==18079== HEAP SUMMARY: ==18079== in use at exit: 21,052 bytes in 90 blocks ==18079== total heap usage: 86,076 allocs, 85,986 frees, 21,097,049 bytes allocated ==18079== ==18079== 4,284 bytes in 83 blocks are definitely lost in loss record 7 of 8 ==18079== at 0x48CC8A8: malloc (vg_replace_malloc.c:446) ==18079== by 0x5048423: wcsdup (wcsdup.c:28) ==18079== by 0x4010D26: c32dup (char32.c:78) ==18079== by 0x4047026: xc32dup (xmalloc.c:61) ==18079== by 0x4044766: parse_desktop_file (xdg.c:461) ==18079== by 0x404602F: scan_dir (xdg.c:694) ==18079== by 0x4046296: xdg_find_programs (xdg.c:736) ==18079== by 0x40215FB: populate_apps (main.c:612) ==18079== by 0x501C31C: start_thread (pthread_create.c:451) ==18079== by 0x509C653: clone (clone.S:100) ==18079== ==18079== LEAK SUMMARY: ==18079== definitely lost: 4,284 bytes in 83 blocks ==18079== indirectly lost: 0 bytes in 0 blocks ==18079== possibly lost: 0 bytes in 0 blocks ==18079== still reachable: 16,768 bytes in 7 blocks ==18079== suppressed: 0 bytes in 0 blocks ==18079== Reachable blocks (those to which a pointer was found) are not shown. ==18079== To see them, rerun with: --leak-check=full --show-leak-kinds=all ==18079== ==18079== For lists of detected and suppressed errors, rerun with: -s ==18079== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) Note, saved_action_name _is_ used in multiple places in the application struct. This patch uses the original copy in the *first* place, while still strdup():ing it in the rest of the places it's used.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+1 added−10 removed
- other:+1 added−10 removed