diff options
author | Daniel Stenberg <daniel@haxx.se> | 2019-09-19 10:06:01 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2019-09-20 08:07:31 +0200 |
commit | 2ba62322a74a408e90b53afb185ba555a157ecb3 (patch) | |
tree | a09f93efc3cabfba11cfae793ca09f8652c11c65 /lib/mime.c | |
parent | cc95dbd64f35bc11c55c475d32012c5491e2f01b (diff) | |
download | curl-2ba62322a74a408e90b53afb185ba555a157ecb3.tar.gz |
mime: make Curl_mime_duppart() assert if called without valid dst
Fixes warning detected by PVS-Studio
Fixes #4374
Diffstat (limited to 'lib/mime.c')
-rw-r--r-- | lib/mime.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/mime.c b/lib/mime.c index 0fb3ae81c..081e51e50 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -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; |