mruby-bigint (mpz_mod): move mpz_init() to avoid memory leak

This commit is contained in:
Yukihiro "Matz" Matsumoto
2024-07-06 23:05:39 +09:00
parent 0ea1549faa
commit 2488375a35
+2 -1
View File
@@ -620,11 +620,12 @@ mpz_mod(mrb_state *mrb, mpz_t *r, mpz_t *x, mpz_t *y)
{
mpz_t q;
short sn = x->sn;
mpz_init(mrb, &q);
if (x->sn == 0) {
zero(r);
return;
}
mpz_init(mrb, &q);
udiv(mrb, &q, r, x, y);
r->sn = sn;
if (uzero(r))