diff --git a/mrbgems/mruby-bigint/core/bigint.c b/mrbgems/mruby-bigint/core/bigint.c index cac4a266b..fc43499a2 100644 --- a/mrbgems/mruby-bigint/core/bigint.c +++ b/mrbgems/mruby-bigint/core/bigint.c @@ -2767,8 +2767,19 @@ bint_set(mpz_ctx_t *ctx, struct RBigint *b, mpz_t *x) } else { RBIGINT_SET_HEAP(b); - mpz_move(ctx, &b->as.heap, x); +#if MRB_BIGINT_POOL_SIZE > 0 + if (MPZ_HAS_POOL(ctx) && is_pool_memory(x, MPZ_POOL(ctx))) { + /* mpz_move() cannot be used because x is in the pool. */ + mpz_set(ctx, &b->as.heap, x); + mpz_clear(ctx, x); + } + else { +#endif + mpz_move(ctx, &b->as.heap, x); + } +#if MRB_BIGINT_POOL_SIZE > 0 } +#endif } static struct RBigint*