Subject: bug#72446: [PATCH] stat: Fix memleak

From: Dmitry Chestnykh <[email-masked]>
Date: Sat, 3 Aug 2024 19:10:28 +0300

format and format2 strings are allocated
by `malloc()` inside `xasprintf` so the memory
should be freed

* src/stat.c: Call `free()` on `format` and `format2`
---
 src/stat.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/stat.c b/src/stat.c
index 1513abfaa..47f3b5052 100644
--- a/src/stat.c
+++ b/src/stat.c
@@ -1974,5 +1974,7 @@ main (int argc, char *argv[])
            ? do_statfs (argv[i], format)
            : do_stat (argv[i], format, format2));
 
+  free(format);
+  free(format2);
   main_exit (ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
-- 
2.46.0