From: David Tardon Date: Wed, 12 Apr 2023 14:59:21 +0000 (+0200) Subject: systemctl: fix a memory leak X-Git-Tag: v254-rc1~734^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90570f6107794a35a31529f7e253f21cd3c5c9b4;p=thirdparty%2Fsystemd.git systemctl: fix a memory leak 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) --- diff --git a/src/systemctl/systemctl-is-enabled.c b/src/systemctl/systemctl-is-enabled.c index bc4fc54c5ab..8d791deaf1c 100644 --- a/src/systemctl/systemctl-is-enabled.c +++ b/src/systemctl/systemctl-is-enabled.c @@ -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);