Skip to content

Commit

Permalink
[zerocoin] Free memory from ToString()
Browse files Browse the repository at this point in the history
Simple fix for a minor memory leak
  • Loading branch information
Warrows committed May 23, 2019
1 parent 3d496cc commit 9c0329c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libzerocoin/bignum_gmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ std::string CBigNum::ToString(int nBase) const
{
char* c_str = mpz_get_str(NULL, nBase, bn);
std::string str(c_str);
// Free c_str with the right free function:
void (*freefunc)(void *, size_t);
mp_get_memory_functions (NULL, NULL, &freefunc);
freefunc(c_str, strlen(c_str) + 1);

return str;
}

Expand Down

0 comments on commit 9c0329c

Please sign in to comment.