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.
This commit is contained in:
@@ -689,7 +689,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost,
|
|||||||
}
|
}
|
||||||
if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE |
|
if(!(form->flags & (HTTPPOST_FILENAME | HTTPPOST_READFILE |
|
||||||
HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER |
|
HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER |
|
||||||
HTTPPOST_CALLBACK)) ) {
|
HTTPPOST_CALLBACK)) && form->value) {
|
||||||
/* copy value (without strdup; possibly contains null characters) */
|
/* copy value (without strdup; possibly contains null characters) */
|
||||||
form->value = memdup(form->value, form->contentslength);
|
form->value = memdup(form->value, form->contentslength);
|
||||||
if(!form->value) {
|
if(!form->value) {
|
||||||
|
Reference in New Issue
Block a user