summaryrefslogtreecommitdiff
path: root/lib/formdata.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2014-10-08 13:53:41 +0200
committerDaniel Stenberg <daniel@haxx.se>2014-10-08 13:53:41 +0200
commitb74205d022cb4b3e2e3ca8b43bce23aff885dac5 (patch)
treeb2ac0eb5d0deb7a3e3fa2036a1163b221b65cba7 /lib/formdata.c
parenteb1e3a398512381d470ee297920c863c8f379c08 (diff)
downloadgnurl-b74205d022cb4b3e2e3ca8b43bce23aff885dac5.tar.gz
gnurl-b74205d022cb4b3e2e3ca8b43bce23aff885dac5.tar.bz2
gnurl-b74205d022cb4b3e2e3ca8b43bce23aff885dac5.zip
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.
Diffstat (limited to 'lib/formdata.c')
-rw-r--r--lib/formdata.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/formdata.c b/lib/formdata.c
index 2e76994a1..a5ee54602 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) {