From: David Tardon Date: Thu, 6 Nov 2025 12:54:35 +0000 (+0100) Subject: homectl: fix memory leak X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5efcbae259826a184dc962822a4e060a21f5175c;p=thirdparty%2Fsystemd.git homectl: fix memory leak # valgrind --leak-check=full homectl create waldo --real-name=Waldo --disk-size=200M --setopt=FOO=bar Before: ==25155== HEAP SUMMARY: ==25155== in use at exit: 12,879 bytes in 39 blocks ==25155== total heap usage: 90 allocs, 51 frees, 53,964 bytes allocated ==25155== ==25155== 8 bytes in 1 blocks are definitely lost in loss record 4 of 38 ==25155== at 0x4845866: malloc (vg_replace_malloc.c:446) ==25155== by 0x547FC2E: strdup (strdup.c:42) ==25155== by 0x4B2647C: strv_env_replace_strdup_passthrough (env-util.c:435) ==25155== by 0x42D547: parse_argv (homectl.c:3909) ==25155== by 0x43999C: run (homectl.c:5606) ==25155== by 0x4399F5: main (homectl.c:5613) ==25155== ==25155== LEAK SUMMARY: ==25155== definitely lost: 8 bytes in 1 blocks After: ==25224== HEAP SUMMARY: ==25224== in use at exit: 12,871 bytes in 38 blocks ==25224== total heap usage: 90 allocs, 52 frees, 53,964 bytes allocated ==25224== ==25224== LEAK SUMMARY: ==25224== definitely lost: 0 bytes in 0 blocks Follow-up-for: aaf057c4bbc6055040d7d2c1ec3655ff89249ebd --- diff --git a/src/home/homectl.c b/src/home/homectl.c index a73d94744ad..09144fb9090 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -3887,7 +3887,7 @@ static int parse_argv(int argc, char *argv[]) { break; case ARG_SETENV: { - _cleanup_free_ char **l = NULL; + _cleanup_strv_free_ char **l = NULL; _cleanup_(sd_json_variant_unrefp) sd_json_variant *ne = NULL; sd_json_variant *e;