From: Daniel Stenberg Date: Tue, 4 Oct 2016 07:13:02 +0000 (+0200) Subject: formpost: trying to attach a directory no longer crashes X-Git-Tag: curl-7_51_0~124 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdf162af255b8dc1498da6f312f04fe2e83f1a48;p=thirdparty%2Fcurl.git 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 --- diff --git a/lib/formdata.c b/lib/formdata.c index 673759de9d..13901b3304 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)