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:
Yukihiro "Matz" Matsumoto
2024-12-18 10:33:58 +09:00
parent 18cc2cea41
commit c83bddd856
+1 -1
View File
@@ -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 {