bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Fix memleak in getdelim.m4
@ 2020-05-18 10:43 Tim Rühsen
  2020-05-18 11:50 ` Bruno Haible
  2020-05-21 14:32 ` Bruno Haible
  0 siblings, 2 replies; 41+ messages in thread
From: Tim Rühsen @ 2020-05-18 10:43 UTC (permalink / raw)
  To: bug-gnulib


[-- Attachment #1.1.1: Type: text/plain, Size: 1104 bytes --]

With leak sanitizer on, the test for getdelim fails due to a memory leak.

The attached patch fixes it. (Please feel free to amend.)

Regards, Tim

Output from config.log:

configure:26259: checking for working getdelim function
configure:26325: gcc-10 -o conftest -O1 -g -fno-omit-frame-pointer
-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize
=undefined,bool,alignment,null,enum,address,leak,nonnull-attribute
-fno-sanitize-recover=all -fsanitize-address-use-afte
r-scope   conftest.c  >&5
configure:26325: $? = 0
configure:26325: ./conftest

=================================================================
==551573==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x7fb818f56e8f in malloc
(/usr/lib/x86_64-linux-gnu/libasan.so.6+0xa9e8f)
    #1 0x7fb8183f51bf in _IO_getdelim
/build/glibc-WZtAaN/glibc-2.30/libio/iogetdelim.c:62
    #2 0x7fb8198dd72f  (<unknown module>)

SUMMARY: AddressSanitizer: 120 byte(s) leaked in 1 allocation(s).
configure:26325: $? = 1
configure: program exited with status 1

[-- Attachment #1.1.2: 0001-Fix-memleak-in-getdelim-C-code-to-pacify-leak-saniti.patch --]
[-- Type: text/x-patch, Size: 1284 bytes --]

From 0b9451c7c8919121df67b71fdd2f993605c1abc1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tim=20R=C3=BChsen?= <tim.ruehsen@gmx.de>
Date: Mon, 18 May 2020 12:36:16 +0200
Subject: [PATCH] Fix memleak in getdelim C code to pacify leak sanitizer

---
 ChangeLog      | 4 ++++
 m4/getdelim.m4 | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9551d9934..2f7d6d4bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-05-18  Tim Rühsen  <tim.ruehsenqgmx.de>
+
+	* m4/getdelim.m4: Fix memleak.
+
 2020-05-17  Bruno Haible  <bruno@clisp.org>
 
 	Clarify intended usage of the license file modules.
diff --git a/m4/getdelim.m4 b/m4/getdelim.m4
index 9f4c7f6e9..ac3917b11 100644
--- a/m4/getdelim.m4
+++ b/m4/getdelim.m4
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 14
+# getdelim.m4 serial 15
 
 dnl Copyright (C) 2005-2007, 2009-2020 Free Software Foundation, Inc.
 dnl
@@ -42,6 +42,7 @@ AC_DEFUN([gl_FUNC_GETDELIM],
         int len = getdelim (&line, &siz, '\n', in);
         if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
           { free (line); fclose (in); return 2; }
+        free (line);
       }
       {
         /* Test result for a NULL buffer and a non-zero size.
-- 
2.26.2


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply related	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2020-06-06  8:26 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-18 10:43 Fix memleak in getdelim.m4 Tim Rühsen
2020-05-18 11:50 ` Bruno Haible
2020-05-18 18:21   ` Tim Rühsen
2020-05-18 19:44     ` Bruno Haible
2020-05-19 21:47       ` Tim Rühsen
2020-05-19 22:46         ` Bruno Haible
2020-05-20 18:45           ` Tim Rühsen
2020-05-21 14:22             ` relicense module 'group-member' Bruno Haible
2020-05-21 14:44               ` Eric Blake
2020-05-21 15:10                 ` Jim Meyering
2020-05-21 19:46                   ` Bruno Haible
2020-05-21 19:27               ` Paul Eggert
2020-05-21 14:23             ` Fix memleak in getdelim.m4 Bruno Haible
2020-05-20 21:59       ` Tim Rühsen
2020-05-21 14:26         ` Bruno Haible
2020-05-21 16:11           ` Tim Rühsen
2020-05-21 19:31             ` Bruno Haible
2020-05-22 14:03               ` Tim Rühsen
2020-05-22 15:25                 ` Bruno Haible
2020-05-22 20:46                   ` Tim Rühsen
2020-05-23 17:51                     ` Fix exponentl.m4 test Bruno Haible
2020-05-23 18:48                     ` Fix calloc.m4 test Bruno Haible
2020-05-23 20:26                       ` Paul Eggert
2020-05-23 21:53                         ` Bruno Haible
2020-05-24  0:51                           ` Paul Eggert
2020-05-24  7:53                             ` Bruno Haible
2020-06-06  8:19                       ` Bruno Haible
2020-05-23 19:18                     ` Fix invalid use of __builtin_isnanf and __builtin_isnanl Bruno Haible
2020-05-23 20:18                     ` Fix calloc-gnu configure results Bruno Haible
2020-05-23 20:47                     ` Fix memleak in getdelim.m4 Bruno Haible
2020-05-24  8:39                       ` Tim Rühsen
2020-05-21 15:15         ` SA_RESETHAND Bruno Haible
2020-05-21 20:10           ` SA_RESETHAND Paul Eggert
2020-05-21 20:59             ` SA_RESETHAND Bruno Haible
2020-05-21 15:22         ` Fix sanitizer error in fchownat.m4 Bruno Haible
2020-05-21 17:42         ` Fix memleak in glob.m4 Bruno Haible
2020-05-21 18:31         ` Fix memleak in regex.m4 Bruno Haible
2020-05-21 18:40         ` Fix memleak in getdelim.m4 Bruno Haible
2020-05-21 19:30           ` Paul Eggert
2020-05-21 19:38             ` Bruno Haible
2020-05-21 14:32 ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).