aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-10-20 21:56:35 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-10-20 21:56:35 +0000
commit0bb91218c51e7ae04975b9993ec0a5e67da75137 (patch)
tree02d45b1fd55c0e4aefd0a7c05c944eb424a0aa98
parent231a51fe7ac4f21d3e8d6dd5b6e039e1aa304406 (diff)
added a NULL pointer check for the name field as it can in fact be NULL when
dereferenced here, if the app passes in a funny combo. Detected by coverity.com
-rw-r--r--lib/formdata.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/formdata.c b/lib/formdata.c
index 62409ec41..e035271b3 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -743,8 +743,11 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
}
if( !(form->flags & HTTPPOST_PTRNAME) &&
(form == first_form) ) {
- /* copy name (without strdup; possibly contains null characters) */
- form->name = memdup(form->name, form->namelength);
+ /* Note that there's small risk that form->name is NULL here if the
+ app passed in a bad combo, so we better check for that first. */
+ if(form->name)
+ /* copy name (without strdup; possibly contains null characters) */
+ form->name = memdup(form->name, form->namelength);
if(!form->name) {
return_value = CURL_FORMADD_MEMORY;
break;