mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
d7ef4355a9
Add overflow protection and memory safety improvements to bigint operations: - Add overflow check in mpz_realloc to prevent integer overflow in size calculations - Fix zero-initialization loop by preserving original size during reallocation - Improve mpz_clear to prevent double-free by nullifying pointer after free - Add bounds checking to mpz_get_str for string conversion buffer allocation - Add documentation comments clarifying memory allocation strategies - Add helper macros MPZ_TMP_INIT/CLEAR for safer temporary variable management These changes prevent potential memory corruption, buffer overflows, and crashes while maintaining full compatibility with existing bigint functionality. Co-authored-by: Claude <noreply@anthropic.com>