diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-10-04 09:13:02 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-10-04 09:13:02 +0200 |
commit | bdf162af255b8dc1498da6f312f04fe2e83f1a48 (patch) | |
tree | 2cc88abcc4b8ce474b8967d8a8c835a9bf41891f | |
parent | 54e48b14e1ecf399149b137bb741cf84a73b1f32 (diff) |
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
-rw-r--r-- | lib/formdata.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/formdata.c b/lib/formdata.c index 673759de9..13901b330 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -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) |