Skip to content

Commit 9c0329c

Browse files
committed
[zerocoin] Free memory from ToString()
Simple fix for a minor memory leak
1 parent 3d496cc commit 9c0329c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libzerocoin/bignum_gmp.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ std::string CBigNum::ToString(int nBase) const
196196
{
197197
char* c_str = mpz_get_str(NULL, nBase, bn);
198198
std::string str(c_str);
199+
// Free c_str with the right free function:
200+
void (*freefunc)(void *, size_t);
201+
mp_get_memory_functions (NULL, NULL, &freefunc);
202+
freefunc(c_str, strlen(c_str) + 1);
203+
199204
return str;
200205
}
201206

0 commit comments

Comments
 (0)