GNU bug report logs - #47384
[PATCH 1/2] hostname: fix a memory leak with -Dlint

Previous Next

Package: coreutils;

Reported by: Kamil Dudka <kdudka <at> redhat.com>

Date: Thu, 25 Mar 2021 10:59:02 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Kamil Dudka <kdudka <at> redhat.com>
To: bug-coreutils <at> gnu.org
Subject: [PATCH 1/2] hostname: fix a memory leak with -Dlint
Date: Thu, 25 Mar 2021 11:57:55 +0100
* src/hostname.c (main): Free allocated memory when compiled
with -Dlint.
---
 src/hostname.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/hostname.c b/src/hostname.c
index 7d13575d4e9..8ec9aad4d34 100644
--- a/src/hostname.c
+++ b/src/hostname.c
@@ -104,6 +104,9 @@ main (int argc, char **argv)
       if (hostname == NULL)
         die (EXIT_FAILURE, errno, _("cannot determine hostname"));
       printf ("%s\n", hostname);
+#ifdef lint
+      free(hostname);
+#endif
     }
 
   if (optind + 1 < argc)
-- 
2.26.3





This bug report was last modified 4 years and 55 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.