mime: make Curl_mime_duppart() assert if called without valid dst

Fixes warning detected by PVS-Studio
Fixes #4374
This commit is contained in:
Daniel Stenberg 2019-09-19 10:06:01 +02:00
parent cc95dbd64f
commit 2ba62322a7
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -1135,6 +1135,8 @@ CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
const curl_mimepart *s;
CURLcode res = CURLE_OK;
DEBUGASSERT(dst);
/* Duplicate content. */
switch(src->kind) {
case MIMEKIND_NONE:
@ -1184,20 +1186,18 @@ CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
}
}
/* Duplicate other fields. */
if(dst != NULL)
if(!res) {
/* Duplicate other fields. */
dst->encoder = src->encoder;
else
res = CURLE_WRITE_ERROR;
if(!res)
res = curl_mime_type(dst, src->mimetype);
}
if(!res)
res = curl_mime_name(dst, src->name);
if(!res)
res = curl_mime_filename(dst, src->filename);
/* If an error occurred, rollback. */
if(res && dst)
if(res)
Curl_mime_cleanpart(dst);
return res;