From 04f07fe1d5f54291f05a9b683294639c5b81faf6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Feb 2026 22:48:21 +0000 Subject: [PATCH] Fix invalid zero representation in set_big_i64 and set_big_ui64 Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com> --- src/util/mpz.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/util/mpz.cpp b/src/util/mpz.cpp index 8445ec134..9b0949114 100644 --- a/src/util/mpz.cpp +++ b/src/util/mpz.cpp @@ -259,6 +259,10 @@ void mpz_manager::sub(mpz const & a, mpz const & b, mpz & c) { template void mpz_manager::set_big_i64(mpz & c, int64_t v) { + if (v == 0) { + set(c, 0); + return; + } uint64_t _v; bool sign = v < 0; if (v == std::numeric_limits::min()) { @@ -309,6 +313,10 @@ void mpz_manager::set_big_i64(mpz & c, int64_t v) { template void mpz_manager::set_big_ui64(mpz & c, uint64_t v) { + if (v == 0) { + set(c, 0); + return; + } #ifndef _MP_GMP if (c.is_small()) { c.set_ptr(allocate(m_init_cell_capacity), false, false); // positive, owned