public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug libc/5666] New: when getline fails it still allocates a buffer @ 2008-01-24 21:00 werner_hahn at yahoo dot de 2008-01-24 21:04 ` [Bug libc/5666] " drepper at redhat dot com ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: werner_hahn at yahoo dot de @ 2008-01-24 21:00 UTC (permalink / raw) To: glibc-bugs This may be a documentation issue. When passing the getline function a NULL pointer as a buffer it is so kind to allocate the needed memory. However when you reach for example EOF and the function returns -1 a buffer of length 120 bytes is allocated anyway which must be freed manually or else is lost. It took me quite some time to find out why valgrind always told me of 120 lost bytes. The documentation does not mention this and so I never suspected this function to be the memory leak. As getline just functions as a wrapper around getdelim the issue should apply to that as well. I give a quick example: char *line = NULL; unsigned int count = 0; count = getline(&line, &count, file_descriptor); if(count == -1) // now line points to 120 bytes of junk { free(line); // without this free the buffer pointed to by line is lost return NULL; } -- Summary: when getline fails it still allocates a buffer Product: glibc Version: 2.3.6 Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: drepper at redhat dot com ReportedBy: werner_hahn at yahoo dot de CC: glibc-bugs at sources dot redhat dot com http://sourceware.org/bugzilla/show_bug.cgi?id=5666 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer 2008-01-24 21:00 [Bug libc/5666] New: when getline fails it still allocates a buffer werner_hahn at yahoo dot de @ 2008-01-24 21:04 ` drepper at redhat dot com 2008-01-25 9:33 ` werner_hahn at yahoo dot de 2008-03-04 18:35 ` drepper at redhat dot com 2 siblings, 0 replies; 4+ messages in thread From: drepper at redhat dot com @ 2008-01-24 21:04 UTC (permalink / raw) To: glibc-bugs ------- Additional Comments From drepper at redhat dot com 2008-01-24 21:03 ------- Do not report problems against anything but the current mainline version. -- What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |WORKSFORME http://sourceware.org/bugzilla/show_bug.cgi?id=5666 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer 2008-01-24 21:00 [Bug libc/5666] New: when getline fails it still allocates a buffer werner_hahn at yahoo dot de 2008-01-24 21:04 ` [Bug libc/5666] " drepper at redhat dot com @ 2008-01-25 9:33 ` werner_hahn at yahoo dot de 2008-03-04 18:35 ` drepper at redhat dot com 2 siblings, 0 replies; 4+ messages in thread From: werner_hahn at yahoo dot de @ 2008-01-25 9:33 UTC (permalink / raw) To: glibc-bugs ------- Additional Comments From werner_hahn at yahoo dot de 2008-01-25 09:32 ------- By looking at the source it seems the issue is present in the current version too. -- What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|WORKSFORME | Version|2.3.6 |unspecified http://sourceware.org/bugzilla/show_bug.cgi?id=5666 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer 2008-01-24 21:00 [Bug libc/5666] New: when getline fails it still allocates a buffer werner_hahn at yahoo dot de 2008-01-24 21:04 ` [Bug libc/5666] " drepper at redhat dot com 2008-01-25 9:33 ` werner_hahn at yahoo dot de @ 2008-03-04 18:35 ` drepper at redhat dot com 2 siblings, 0 replies; 4+ messages in thread From: drepper at redhat dot com @ 2008-03-04 18:35 UTC (permalink / raw) To: glibc-bugs ------- Additional Comments From drepper at redhat dot com 2008-03-04 18:35 ------- There is nothing wrong with the implementation. The buffer, when allocated, is always the callers problem. The whole concept of getline is to reuse buffers. We do not want the getline/getdelim function arbitrarily free the buffer. -- What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |INVALID http://sourceware.org/bugzilla/show_bug.cgi?id=5666 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-03-04 18:35 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-01-24 21:00 [Bug libc/5666] New: when getline fails it still allocates a buffer werner_hahn at yahoo dot de 2008-01-24 21:04 ` [Bug libc/5666] " drepper at redhat dot com 2008-01-25 9:33 ` werner_hahn at yahoo dot de 2008-03-04 18:35 ` drepper at redhat dot com
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).