]> git.kaiwu.me - quickjs.git/commitdiff
memcpy() (currently) has undefined behavior if a pointer is NULL with zero size ...
authorFabrice Bellard <fabrice@bellard.org>
Thu, 14 May 2026 14:21:10 +0000 (16:21 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Thu, 14 May 2026 14:39:41 +0000 (16:39 +0200)
libunicode.c

index 0c510ccb158d1d23f499e48d31955f2979df0747..0b7b6d0b1f09a84f17d7fe18c3492c2d5318afb1 100644 (file)
@@ -1189,7 +1189,8 @@ int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len,
                 goto not_latin1;
         }
         buf = (int *)dbuf->buf;
-        memcpy(buf, src, src_len * sizeof(int));
+        if (src_len != 0)
+            memcpy(buf, src, src_len * sizeof(int));
         *pdst = (uint32_t *)buf;
         return src_len;
     not_latin1: ;