From c7aa86ce6f17f52aadff898b79c95d968da6bfa2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 25 Apr 2017 12:06:10 +1000 Subject: [PATCH] py/mpz: Strip trailing zeros from mpz value when set from bytes. --- py/mpz.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py/mpz.c b/py/mpz.c index 72d226cb3f..c6832e3898 100644 --- a/py/mpz.c +++ b/py/mpz.c @@ -938,6 +938,8 @@ void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf) #endif num_bits -= DIG_SIZE; } + + z->len = mpn_remove_trailing_zeros(z->dig, z->dig + z->len); } bool mpz_is_zero(const mpz_t *z) {