Skip to content

Commit

Permalink
Fix memory leak in hex_str / hex_str_upper
Browse files Browse the repository at this point in the history
  • Loading branch information
bacam committed Dec 10, 2024
1 parent c050b3d commit 58b7d87
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/sail.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ void hex_str(sail_string *str, const mpz_t n)
mpz_init(abs);
mpz_abs(abs, n);
gmp_asprintf(str, "-0x%Zx", abs);
mpz_clear(abs);
} else {
gmp_asprintf(str, "0x%Zx", n);
}
Expand All @@ -184,6 +185,7 @@ void hex_str_upper(sail_string *str, const mpz_t n)
mpz_init(abs);
mpz_abs(abs, n);
gmp_asprintf(str, "-0x%ZX", abs);
mpz_clear(abs);
} else {
gmp_asprintf(str, "0x%ZX", n);
}
Expand Down

0 comments on commit 58b7d87

Please sign in to comment.