Skip to content

Commit

Permalink
abi: export right mpz after masking
Browse files Browse the repository at this point in the history
  • Loading branch information
mhw0 committed Sep 15, 2023
1 parent f016cbf commit ecbc72f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ int eth_abi_mpint(struct eth_abi *abi, mpz_t mpz) {

size = mpz_sizeinbase(mpztmp, 16);
size = (size % 2 == 0 ? size : size + 1) / 2;
mpz_export((bytes + 32) - size, NULL, 1, sizeof(uint8_t), 0, 0, mpz);
mpz_export((bytes + 32) - size, NULL, 1, sizeof(uint8_t), 0, 0, mpztmp);
mpz_clears(mpztmp, mpzmask, NULL);

return eth_abi_bytes32(abi, bytes);
Expand Down
2 changes: 1 addition & 1 deletion test/test-eth-abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void test_eth_abi_mpint(void) {

mpz_init_set_str(mpz0, "0xff", 0);
mpz_init_set_str(mpz1, "0xfff", 0);
mpz_init_set_str(mpz2, "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbb", 0);
mpz_init_set_str(mpz2, "0xbbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 0);

ok(eth_abi_init(&abi0, ETH_ABI_ENCODE) == 1);
ok(eth_abi_mpint(&abi0, mpz0) == 1);
Expand Down

0 comments on commit ecbc72f

Please sign in to comment.