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

yubiao hu <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <CADzWzW9UW1=05R+kYc4wOnWv1_815N0SVT30+776VMb7OnmNXw@mail.gmail.com>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.