mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-bigint (bint_new): avoid memcpy'ing NULL pointer
The second argument of memcpy() is declared to never be NULL. Clang ASAN report this as an undefined behavior error.
This commit is contained in:
@@ -1263,7 +1263,7 @@ bint_new(mrb_state *mrb, mpz_t *x)
|
||||
if (x->sz <= RBIGINT_EMBED_SIZE_MAX) {
|
||||
RBIGINT_SET_EMBED_SIZE(b, x->sz);
|
||||
RBIGINT_SET_EMBED_SIGN(b, x->sn);
|
||||
memcpy(RBIGINT_EMBED_ARY(b), x->p, x->sz*sizeof(mp_limb));
|
||||
if (x->p) memcpy(RBIGINT_EMBED_ARY(b), x->p, x->sz*sizeof(mp_limb));
|
||||
mpz_clear(mrb, x);
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user