Closed
Labels
Description
curl/docs/examples/getinmemory.c
Lines 45 to 50 in 5bd8c38
| mem->memory = realloc(mem->memory, mem->size + realsize + 1); | |
| if(mem->memory == NULL) { | |
| /* out of memory! */ | |
| printf("not enough memory (realloc returned NULL)\n"); | |
| return 0; | |
| } |
realloc can return null if he can't extend the memory. This case here envisaged, but...realloc doesn't clean memory. We got a memory leak if realloc return null.
If we open realloc documentation, we can see:
A null-pointer indicates that the function failed to allocate storage, and thus the block pointed by ptr was not modified.
Activity
danielgustafsson commentedon Sep 14, 2018
danielgustafsson commentedon Sep 14, 2018
CrazyHackGUT commentedon Sep 14, 2018
Ok, I create PR later.
danielgustafsson commentedon Sep 14, 2018
Fix memory leak
CrazyHackGUT commentedon Sep 15, 2018
I missed one time and created pull also in my fork 🤣
Just ignore him in this issue.
bagder commentedon Sep 18, 2018
Fixed in 23524bf