svn commit: r202947 - stable/8/lib/libc/stdio

David Schultz das at FreeBSD.org
Sun Jan 24 20:16:00 UTC 2010


Author: das
Date: Sun Jan 24 20:15:59 2010
New Revision: 202947
URL: http://svn.freebsd.org/changeset/base/202947

Log:
  MFC r197752:
  
    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.

Modified:
  stable/8/lib/libc/stdio/getdelim.c

Modified: stable/8/lib/libc/stdio/getdelim.c
==============================================================================
--- stable/8/lib/libc/stdio/getdelim.c	Sun Jan 24 19:36:43 2010	(r202946)
+++ stable/8/lib/libc/stdio/getdelim.c	Sun Jan 24 20:15:59 2010	(r202947)
@@ -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. */


More information about the svn-src-stable-8 mailing list