From: Daniel Stenberg Date: Wed, 8 Oct 2014 11:53:41 +0000 (+0200) Subject: FormAdd: precaution against memdup() of NULL pointer X-Git-Tag: curl-7_39_0~167 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b74205d022cb4b3e2e3ca8b43bce23aff885dac5;p=thirdparty%2Fcurl.git FormAdd: precaution against memdup() of NULL pointer Coverity CID 252518. This function is in general far too complicated for its own good and really should be broken down into several smaller funcitons instead - but I'm adding this protection here now since it seems there's a risk the code flow can end up here and dereference a NULL pointer. --- diff --git a/lib/formdata.c b/lib/formdata.c index 2e76994a12..a5ee546026 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -689,7 +689,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, } if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE | HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER | - HTTPPOST_CALLBACK)) ) { + HTTPPOST_CALLBACK)) && form->value) { /* copy value (without strdup; possibly contains null characters) */ form->value = memdup(form->value, form->contentslength); if(!form->value) {