Subject: bug#79331: [PATCH] expr: fix memory leaks

From: yubiao hu <[email-masked]>
Date: Thu, 28 Aug 2025 15:51:56 +0800

fix: https://lists.gnu.org/archive/html/bug-coreutils/2025-08/msg00094.html

---
 src/expr.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/expr.c b/src/expr.c
index cd87763..534bb44 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -93,6 +93,7 @@ static VALUE *eval (bool);
 static bool nomoreargs (void);
 static bool null (VALUE *v);
 static void printv (VALUE *v);
+static void freev (VALUE *v);

 /*
@@ -307,6 +308,7 @@ int
 main (int argc, char **argv)
 {
   VALUE *v;
+  bool exit_status = true;

   initialize_main (&argc, &argv);
   set_program_name (argv[0]);
@@ -343,7 +345,11 @@ main (int argc, char **argv)

   printv (v);

-  main_exit (null (v));
+  exit_status = null (v);
+
+  freev (v);
+
+  main_exit (exit_status);
 }

 /* Return a VALUE for I.  */
-- 
2.33.0