cURL / Mailing Lists / curl-library / Single Mail


Re: [EXAMPLE] Bug in getinmemory.c

From: Dan Fandrich <>
Date: Tue, 10 May 2011 11:50:45 -0700

On Tue, May 10, 2011 at 07:42:52PM +0200, Martin Möller wrote:
> I found a bug in getinmemory.c in docs/examples.
> This version misuses realloc: It resizes a chunk of memory, but doesn?t take
> into
> account that the realloced memory address changes.

If realloc changes the memory address, it is responsible for moving the
contents of the old block to the new one. At worst, the code as it stands
will suffer from a memory leak if the realloc fails, but it should execute
fine. Are you seeing an actual problem when running the example?

>>> Dan
List admin:
Received on 2011-05-10