Skip to content

Commit

Permalink
formpost: trying to attach a directory no longer crashes
Browse files Browse the repository at this point in the history
The error path would previously add a freed entry to the linked list.

Reported-by: Toby Peterson

Fixes curl#1053
  • Loading branch information
bagder committed Oct 4, 2016
1 parent 54e48b1 commit bdf162a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/formdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit bdf162a

Please sign in to comment.