From e84d87d8d92b522691271f7df53c52b182c30c13 Mon Sep 17 00:00:00 2001 From: Brian Campbell Date: Tue, 10 Dec 2024 14:30:01 +0000 Subject: [PATCH] Fix memory leak in hex_str / hex_str_upper --- lib/sail.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/sail.c b/lib/sail.c index cdd9a0336..8db2ab1ba 100644 --- a/lib/sail.c +++ b/lib/sail.c @@ -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); } @@ -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); }