Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Oct 2009 19:43:36 +0000 (UTC)
From:      David Schultz <das@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r197752 - head/lib/libc/stdio
Message-ID:  <200910041943.n94JhaDg083487@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: das
Date: Sun Oct  4 19:43:36 2009
New Revision: 197752
URL: http://svn.freebsd.org/changeset/base/197752

Log:
  Better glibc compatibility for getline/getdelim:
  
  - Tolerate applications that pass a NULL pointer for the buffer and
    claim that the capacity of the buffer is nonzero.
  
  - If an application passes in a non-NULL buffer pointer and claims the
    buffer has zero capacity, we should free (well, realloc) it
    anyway. It could have been obtained from malloc(0), so failing to
    free it would be a small memory leak.
  
  MFC After:	2 weeks
  Reported by:	naddy
  PR:		ports/138320

Modified:
  head/lib/libc/stdio/getdelim.c

Modified: head/lib/libc/stdio/getdelim.c
==============================================================================
--- head/lib/libc/stdio/getdelim.c	Sun Oct  4 19:03:32 2009	(r197751)
+++ head/lib/libc/stdio/getdelim.c	Sun Oct  4 19:43:36 2009	(r197752)
@@ -120,8 +120,8 @@ getdelim(char ** __restrict linep, size_
 		goto error;
 	}
 
-	if (*linecapp == 0)
-		*linep = NULL;
+	if (*linep == NULL)
+		*linecapp = 0;
 
 	if (fp->_r <= 0 && __srefill(fp)) {
 		/* If fp is at EOF already, we just need space for the NUL. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200910041943.n94JhaDg083487>