--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#47384: [PATCH 1/2] hostname: fix a memory leak with -Dlint |
Date: |
Thu, 25 Mar 2021 11:22:33 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 |
On 3/25/21 11:16 AM, Paul Eggert wrote:
I'd prefer it to use IF_LINT (as in the earlier
change), as that makes it cleaner since it's just one line of useless
code, not three.
Installed as attached, and closing the bug report. Thanks again.
0001-hostname-pacify-valgrind.patch
Description: Text Data
--- End Message ---