formpost: trying to attach a directory no longer crashes

The error path would previously add a freed entry to the linked list.

Reported-by: Toby Peterson

Fixes #1053
This commit is contained in:
Daniel Stenberg 2016-10-04 09:13:02 +02:00
parent 54e48b14e1
commit bdf162af25

View File

@ -863,13 +863,6 @@ static CURLcode AddFormData(struct FormData **formp,
newform->type = type;
if(*formp) {
(*formp)->next = newform;
*formp = newform;
}
else
*formp = newform;
if(size) {
if(type != FORM_FILE)
/* for static content as well as callback data we add the size given
@ -889,6 +882,14 @@ static CURLcode AddFormData(struct FormData **formp,
}
}
}
if(*formp) {
(*formp)->next = newform;
*formp = newform;
}
else
*formp = newform;
return CURLE_OK;
error:
if(newform)