summaryrefslogtreecommitdiff
path: root/libarchive/archive_string.c
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@bec.de>2017-08-01 17:17:45 +0200
committerJoerg Sonnenberger <joerg@bec.de>2017-08-01 17:17:45 +0200
commit9d5e5f32208a42fc3e7986645a791524939aa9e4 (patch)
treec33e1cb30c33adaad41c3624c956384b3b3d8a8b /libarchive/archive_string.c
parentde20494ba2a4fcff8b56010faa75467ad8d5a40b (diff)
downloadlibarchive-9d5e5f32208a42fc3e7986645a791524939aa9e4.tar.gz
Don't call wmemmove if size is zero.
The data pointers can be NULL in this case and ISO C says this is UB.
Diffstat (limited to 'libarchive/archive_string.c')
-rw-r--r--libarchive/archive_string.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libarchive/archive_string.c b/libarchive/archive_string.c
index 5ae09b62..392cc110 100644
--- a/libarchive/archive_string.c
+++ b/libarchive/archive_string.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_string.c 201095 2009-12-28 02:33
* without incurring additional memory allocations.
*/
+#include <assert.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -214,7 +215,9 @@ archive_wstring_append(struct archive_wstring *as, const wchar_t *p, size_t s)
{
if (archive_wstring_ensure(as, as->length + s + 1) == NULL)
return (NULL);
- wmemmove(as->s + as->length, p, s);
+ assert(p != NULL);
+ if (s)
+ wmemmove(as->s + as->length, p, s);
as->length += s;
as->s[as->length] = 0;
return (as);