diff options
author | Charlie Gordon <github@chqrlie.org> | 2024-03-03 14:05:40 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-13 21:07:12 +0100 |
commit | 531bb1cc261be1e89e398417760fca1261583582 (patch) | |
tree | b791e16868a9eb5a4dc0865b97dc1266b19e6fde /lib/quickjs/cutils.c | |
parent | 570a601e8f88d28d747a373cdb3db3405bb1c6fc (diff) | |
download | chawan-531bb1cc261be1e89e398417760fca1261583582.tar.gz |
Prevent UB on memcpy and floating point conversions
- add `memcpy_no_ub` that accepts null pointers for 0 count - prevent 0 length allocation in `js_worker_postMessage` - use safer test for `int` value in `JS_NewFloat64`, `JS_ToArrayLengthFree` and `js_typed_array_indexOf`
Diffstat (limited to 'lib/quickjs/cutils.c')
-rw-r--r-- | lib/quickjs/cutils.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/quickjs/cutils.c b/lib/quickjs/cutils.c index b4960f9c..c0aacef6 100644 --- a/lib/quickjs/cutils.c +++ b/lib/quickjs/cutils.c @@ -140,7 +140,7 @@ int dbuf_put(DynBuf *s, const uint8_t *data, size_t len) if (dbuf_realloc(s, s->size + len)) return -1; } - memcpy(s->buf + s->size, data, len); + memcpy_no_ub(s->buf + s->size, data, len); s->size += len; return 0; } |