]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
FormAdd: precaution against memdup() of NULL pointer
authorDaniel Stenberg <daniel@haxx.se>
Wed, 8 Oct 2014 11:53:41 +0000 (13:53 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 8 Oct 2014 11:53:41 +0000 (13:53 +0200)
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.

lib/formdata.c

index 2e76994a12c61e32c04238447c408ef08da96a2d..a5ee546026ec7e8a7efc3f489f09dd22dc363c12 100644 (file)
@@ -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) {