]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
manual: clarify buffer behavior in getline [BZ #5666]
authorDavid Svoboda <svoboda@cert.org>
Wed, 2 Apr 2014 09:13:02 +0000 (05:13 -0400)
committerMike Frysinger <vapier@gentoo.org>
Thu, 3 Apr 2014 22:23:57 +0000 (18:23 -0400)
If the user has requested automatic buffer creation, getline may create
it and not free things when an error occurs.  That means the user is
always responsible for calling free() regardless of the return value.

The current documentation does not explicitly cover this which leaves it
slightly ambiguous to the reader.  So clarify things.

URL: https://sourceware.org/bugzilla/show_bug.cgi?id=5666

ChangeLog
manual/stdio.texi

index 7a1c10620ae2b3fa19ef9d803b6d658c7847619e..da8ea6d06f10b33d19cb77665a553060b907427f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-04-03  David Svoboda  <svoboda@cert.org>
+
+       [BZ #5666]
+       * manual/stdio.texi (Line-Oriented Input): Document buffer allocation
+       explicitly.
+
 2014-04-03  Roland McGrath  <roland@hack.frob.com>
 
        * elf/dl-unmap-segments.h: New file.
index a4364f79f994f511de95efd168b0ef11d9c21c20..efdaaadf27a0681aee1a2e670d1af6ad4b870548 100644 (file)
@@ -1298,7 +1298,8 @@ back in @code{*@var{n}}.
 
 If you set @code{*@var{lineptr}} to a null pointer, and @code{*@var{n}}
 to zero, before the call, then @code{getline} allocates the initial
-buffer for you by calling @code{malloc}.
+buffer for you by calling @code{malloc}.  This buffer remains allocated
+even if @code{getline} encounters errors and is unable to read any bytes.
 
 In either case, when @code{getline} returns,  @code{*@var{lineptr}} is
 a @code{char *} which points to the text of the line.