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`
This commit is contained in:
Charlie Gordon
2024-03-03 14:05:40 +01:00
parent 3dd93eb4e4
commit 06c100c9bf
5 changed files with 26 additions and 18 deletions

View File

@@ -309,7 +309,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;
}