Skip to content

Commit c7aa86c

Browse files
committed
py/mpz: Strip trailing zeros from mpz value when set from bytes.
1 parent 5e66f2b commit c7aa86c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

py/mpz.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,8 @@ void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf)
938938
#endif
939939
num_bits -= DIG_SIZE;
940940
}
941+
942+
z->len = mpn_remove_trailing_zeros(z->dig, z->dig + z->len);
941943
}
942944

943945
bool mpz_is_zero(const mpz_t *z) {

0 commit comments

Comments
 (0)