This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug manual/156] New: Info for gethostbyname_r doesn't say when temp buffer can be freed
- From: "spam_from_glibc_bugzilla at chezphil dot org" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 12 May 2004 13:54:27 -0000
- Subject: [Bug manual/156] New: Info for gethostbyname_r doesn't say when temp buffer can be freed
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
The info page for gethostbyname[2]_r describes the function and gives an
example, but says nothing about when the "temporary" buffer passed via the BUF
parameter can be freed. I made the mistake of freeing it shortly after the
call, which works for me 99% of the time but failed in a hard-to-debug way when
my code tried to look up "localhost". I think that some of the pointers
(h_addr_list?) in the returned hostent struct point into this "temporary" space.
In many applications it will not be acceptable to allow this memory to leak (the
example code allocates at least 1k for each call). I suggest adding a line as
follows, but would appreciate it if someone could confirm that this is actually
correct:
"The buffer passed as the BUF parameter can be freed only once the caller has
finished with the result hostent struct, or has copied it including all the
other memory that it points to."
Appologies if I am missing something....
(I'm using glibc 2.3.2 on Debian Testing)
--
Summary: Info for gethostbyname_r doesn't say when temp buffer
can be freed
Product: glibc
Version: 2.3.2
Status: NEW
Severity: normal
Priority: P2
Component: manual
AssignedTo: roland at gnu dot org
ReportedBy: spam_from_glibc_bugzilla at chezphil dot org
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=156
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.