$ 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.
---
 src/ls.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ls.c b/src/ls.c
index a4be6fcea..0b4695a33 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++;
-- 
2.55.0


Reply via email to