[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gcc 2.2.5 online manual contains bug in gethostbyname_r example

From: Bossom, John
Subject: gcc 2.2.5 online manual contains bug in gethostbyname_r example
Date: Thu, 25 Sep 2003 16:57:40 -0400


I was tracking down some documentation on gethostbyname_r and was staring at the
example on the document (link provided below) and noticed a coding error...

The example declares a local instance of "struct hostent hostbuf" and at the bottom
of the routine, it returns the pointer "hp" that had been returned by gethostbyname_r;
however, this pointer simply contains the address of the struct passed into hostbuf...
Hence, it is returning a pointer to a stack based variable which is immediately
invalid upon returning from the routine....

John E. Bossom


Join us at Cognos' biggest event of the year Enterprise 2003, The Cognos Business Forum.  Taking place in over 25 cities around the world, it's an opportunity for Business and IT leaders to learn about strategies for driving performance. Visit http://www.cognos.com/enterprise03 for more details.

This message may contain privileged and/or confidential information.  If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.  Thank you.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]