cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Memory leak in getinmemory.c example?

From: <henrik_at_gassmann.onl>
Date: Sun, 6 Dec 2015 15:31:08 +0000

On Sun, 6 Dec 2015, Daniel Stenberg wrote:
> That is entirely correct. But this is an example that is meant to be simple and
> easy to read.

I generally agree, but in this particular case the leak can be prevented easily enough:
> char *tmp = realloc(mem->memory, mem->size + realsize + 1);
> if (tmp) { /* out of memory! */ /*...*/ return 0; }
> mem->memory = tmp;

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