Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com To: "Cygwin Mailing List" Subject: Re: cygwin programs: realloc() segfault with library v1.3.1 References: <001001c0d192$1cb70240$0101a8c0 AT luckynet DOT adm> From: Benjamin Riefenstahl Date: 02 May 2001 19:00:49 +0200 In-Reply-To: "Thunder from the hill"'s message of "Mon, 30 Apr 2001 09:21:33 -0700" Message-ID: Lines: 37 User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii "Thunder from the hill" writes: > Again, this is the failing source code. Whenever realloc() is used > in sendfile(), the MicroHTTPD segfaults. As Chris says, you should limit examples. Anyway I looked at your code and your use of realloc(). You never do anything with the result of your calls. That won't work. realloc() is designed to be used as void * some_buffer = NULL; ... some_buffer = realloc( some_buffer, newlen ); or better, with minimal error handling: void * some_buffer = NULL; void * temp; ... temp = realloc( some_buffer, newlen ); if( NULL != temp ) some_buffer = temp; In your code OTOH, all the allocated memory returned by realloc() is just ignored so your code continues to read and write from the (now probably invalid) previous pointer. Note also that you will have to redesign the interface for your clear() function to account for this usage. so long, benny -- ISION Internet AG Benjamin Riefenstahl mailto:benjamin DOT riefenstahl AT ision DOT net Harburger Schlossstr. 1 D-21079 Hamburg http://www.ision.net -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple