]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: fix a memory leak
authorDavid Tardon <dtardon@redhat.com>
Wed, 12 Apr 2023 14:59:21 +0000 (16:59 +0200)
committerDavid Tardon <dtardon@redhat.com>
Wed, 12 Apr 2023 15:13:52 +0000 (17:13 +0200)
valgrind systemctl is-enabled --root=/ -l default.target >/dev/null
==746041== Memcheck, a memory error detector
==746041== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==746041== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==746041== Command: systemctl is-enabled --root=/ -l default.target
==746041==
==746041==
==746041== HEAP SUMMARY:
==746041==     in use at exit: 8,251 bytes in 4 blocks
==746041==   total heap usage: 3,440 allocs, 3,436 frees, 1,163,346 bytes allocated
==746041==
==746041== LEAK SUMMARY:
==746041==    definitely lost: 24 bytes in 1 blocks
==746041==    indirectly lost: 35 bytes in 1 blocks
==746041==      possibly lost: 0 bytes in 0 blocks
==746041==    still reachable: 8,192 bytes in 2 blocks
==746041==         suppressed: 0 bytes in 0 blocks
==746041== Rerun with --leak-check=full to see details of leaked memory
==746041==
==746041== For lists of detected and suppressed errors, rerun with: -s
==746041== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

src/systemctl/systemctl-is-enabled.c

index bc4fc54c5ab2262645bb10eb063163bc341a0529..8d791deaf1c9922227a4c1b883450935a4ac7430 100644 (file)
@@ -14,6 +14,8 @@ static int show_installation_targets_client_side(const char *name) {
         char **p;
         int r;
 
+        CLEANUP_ARRAY(changes, n_changes, install_changes_free);
+
         p = STRV_MAKE(name);
         flags = UNIT_FILE_DRY_RUN |
                 (arg_runtime ? UNIT_FILE_RUNTIME : 0);