-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Description
Cppcheck highlighted this code. lib\formdata.c contains this code with two early returns either of which results in having memory pointed to my newform leaked.
static CURLcode AddFormData( PARAMS HERE)
{
struct FormData *newform = malloc(sizeof(struct FormData));
if(!newform)
return CURLE_OUT_OF_MEMORY;
newform->next = NULL;
if(length < 0 || (size && *size < 0))
/* MEMORY LEAK - newform is not freed */
return CURLE_BAD_FUNCTION_ARGUMENT;
if(type <= FORM_CONTENT) {
if(!length)
/*WHATEVER*/
else if(length >= (curl_off_t)(size_t)-1)
/* MEMORY LEAK - newform is not freed */
return CURLE_BAD_FUNCTION_ARGUMENT;