From bdf162af255b8dc1498da6f312f04fe2e83f1a48 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 4 Oct 2016 09:13:02 +0200 Subject: 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 --- lib/formdata.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/formdata.c') 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) -- cgit v1.2.3