From: Pádraig Brady Date: Wed, 22 Jul 2026 19:36:42 +0000 (+0100) Subject: ls: fix a small mem leak when CLI args have errors X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=1f681f8a7212e4f40addf54fb355aac906b85bee;p=thirdparty%2Fcoreutils.git ls: fix a small mem leak when CLI args have errors $ valgrind --quiet --leak-check=full --show-leak-kinds=definite \ src/ls --hyperlink=always foo bar ls: cannot access 'foo': No such file or directory ls: cannot access 'bar': No such file or directory 32 bytes in 1 blocks are definitely lost in loss record 3 of 7 at malloc (vg_replace_malloc.c:447) by canonicalize_filename_mode_stk (canonicalize.c:450) by canonicalize_filename_mode (canonicalize.c:471) by gobble_file.constprop.0 (ls.c:3392) by main (ls.c:1765) * src/ls.c (gobble_file): Call free_ent() before returning. --- diff --git a/src/ls.c b/src/ls.c index a4be6fcea0..0b4695a333 100644 --- a/src/ls.c +++ b/src/ls.c @@ -3464,7 +3464,10 @@ gobble_file (char const *name, enum filetype type, ino_t inode, _("cannot access %s"), full_name); if (command_line_arg) - return 0; + { + free_ent (f); + return 0; + } f->name = xstrdup (name); cwd_n_used++;