curl-library
Memory leak in getinmemory.c example?
From: <henrik_at_gassmann.onl>
Date: Sun, 6 Dec 2015 13:06:58 +0000
Date: Sun, 6 Dec 2015 13:06:58 +0000
Hello everyone,
I think there is a memory leak in http://curl.haxx.se/libcurl/c/getinmemory.html WriteMemoryCallback() :
> mem->memory = realloc(mem->memory, mem->size + realsize + 1);
Correct me if I am wrong, but according to http://en.cppreference.com/w/c/memory/realloc you still have to free the old pointer if realloc fails (i.e. returns NULL), which is obviously impossible if you directly overwrite it.
Kind regards
Henrik S. Gaßmann
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-12-06