summaryrefslogtreecommitdiff
path: root/libs/libcurl/src/strdup.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libcurl/src/strdup.c')
-rw-r--r--libs/libcurl/src/strdup.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libs/libcurl/src/strdup.c b/libs/libcurl/src/strdup.c
index f3d8ed3846..94caa05fb8 100644
--- a/libs/libcurl/src/strdup.c
+++ b/libs/libcurl/src/strdup.c
@@ -104,7 +104,7 @@ void *Curl_memdup(const void *src, size_t length)
* Curl_memdup0(source, length)
*
* Copies the 'source' string to a newly allocated buffer (that is returned).
- * Copies 'length' bytes then adds a null terminator.
+ * Copies 'length' bytes then adds a null-terminator.
*
* Returns the new pointer or NULL on failure.
*
@@ -114,7 +114,10 @@ void *Curl_memdup0(const char *src, size_t length)
char *buf = malloc(length + 1);
if(!buf)
return NULL;
- memcpy(buf, src, length);
+ if(length) {
+ DEBUGASSERT(src); /* must never be NULL */
+ memcpy(buf, src, length);
+ }
buf[length] = 0;
return buf;
}