]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
disk-utils: fix memory leak in execute function
authorTigran Sogomonian <tsogomonian@astralinux.ru>
Mon, 29 Jun 2026 12:52:06 +0000 (15:52 +0300)
committerTigran Sogomonian <tsogomonian@astralinux.ru>
Mon, 29 Jun 2026 12:52:06 +0000 (15:52 +0300)
Dynamic memory, referenced by 'argv', is allocated by calling function
'xstrdup' and lost when function returns.

Found by the static analyzer Svace.

Signed-off-by: Tigran Sogomonian <tsogomonian@astralinux.ru>
disk-utils/fsck.c

index cf9c8e4206ad73a9fd12ea9f788ab9c13377a049..3f972cff513cf7f4b4ec3f4bf981e4bf9b293a53 100644 (file)
@@ -682,6 +682,8 @@ static int execute(const char *progname, const char *progpath,
                pid = -1;
        else if ((pid = fork()) < 0) {
                warn(_("fork failed"));
+               for (i = 0; i < argc; i++)
+                       free(argv[i]);
                free_instance(inst);
                return errno;
        } else if (pid == 0) {