mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
f2f385f572
When shift amount is 0, urshift() and ulshift() called mpz_set() which copies data without trimming leading zero limbs. This caused bigint values to have inflated sz fields, making ucmp() comparisons incorrect. For example, a 256-bit remainder from division could have sz=18 instead of sz=8 because the divisor had 18 limbs. This made it compare greater than values with fewer limbs, even when numerically smaller. The bug also caused memory leaks when the incorrect comparison led to taking wrong code paths in division, triggering size overflow exceptions after memory was allocated. Co-authored-by: Claude <noreply@anthropic.com>