about summary refs log tree commit diff stats
path: root/lib/quickjs/libbf.c
diff options
context:
space:
mode:
authorCharlie Gordon <github@chqrlie.org>2024-03-03 14:05:40 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-13 21:07:12 +0100
commit531bb1cc261be1e89e398417760fca1261583582 (patch)
treeb791e16868a9eb5a4dc0865b97dc1266b19e6fde /lib/quickjs/libbf.c
parent570a601e8f88d28d747a373cdb3db3405bb1c6fc (diff)
downloadchawan-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/libbf.c')
-rw-r--r--lib/quickjs/libbf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/quickjs/libbf.c b/lib/quickjs/libbf.c
index a7d36c28..7f497a85 100644
--- a/lib/quickjs/libbf.c
+++ b/lib/quickjs/libbf.c
@@ -311,7 +311,7 @@ int bf_set(bf_t *r, const bf_t *a)
     }
     r->sign = a->sign;
     r->expn = a->expn;
-    memcpy(r->tab, a->tab, a->len * sizeof(limb_t));
+    memcpy_no_ub(r->tab, a->tab, a->len * sizeof(limb_t));
     return 0;
 }