coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] nl: free allocated strings to avoid valgrind warning


From: Pádraig Brady
Subject: Re: [PATCH] nl: free allocated strings to avoid valgrind warning
Date: Mon, 11 Apr 2016 22:16:57 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/04/16 18:56, Daniel Lockyer wrote:
On Mon, Apr 11, 2016 at 06:44:41PM +0100, Pádraig Brady wrote:
On 11/04/16 18:30, Daniel Lockyer wrote:
* src/nl.c (main): free (with IF_LINT guarding) header_del, body_del,
      footer_del and print_no_line_fmt to keep valgrind quiet about
      not being free before exiting.
---
   src/nl.c | 5 +++++
   1 file changed, 5 insertions(+)

diff --git a/src/nl.c b/src/nl.c
index a4a48bc..4064822 100644
--- a/src/nl.c
+++ b/src/nl.c
@@ -586,5 +586,10 @@ main (int argc, char **argv)
     if (have_read_stdin && fclose (stdin) == EOF)
       error (EXIT_FAILURE, errno, "-");

+  IF_LINT (free (header_del));
+  IF_LINT (free (body_del));
+  IF_LINT (free (footer_del));
+  IF_LINT (free (print_no_line_fmt));
+
     return ok ? EXIT_SUCCESS : EXIT_FAILURE;
   }


This is just a "still reachable" warning I think.
We only consider freeing stuff when valgrind marks it as "definitely lost",
which was the case for your previous date.c patch but not here?

cheers,
Pádraig

You are correct, it is. I didn't know that was a condition but no
worries, I'll keep searching!

Theoretically that could be automated by setting up valgrind wrappers using:
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=blob;f=README-valgrind;hb=HEAD
and using the--errors-for-leak-kinds=definite option

cheers,
Pádraig



reply via email to

[Prev in Thread] Current Thread [Next in Thread]