On Mon, 4 Jan 2010, Lars Nilsson wrote:

       mem->memory = (char *)realloc(mem->memory, mem->size + realsize
+ 1);                 // Application crashes here.

Well yes, as 'mem' is NULL...

realloc() shouldn't have a problem dealing with a NULL pointer.

Right, but the code never reaches realloc(). Read the code again and notice that 'mem' is NULL in the above scenario. It will try to read data from a struct at adress 0x0 and that won't work. 'mem->memory' is illegal (and so is mem->size).

--

 / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to