Comparing bombela:master...ogdf:master · bombela/backward-cpp
Commits on Aug 24, 2016
-
Fix memory leak in linux demangler
The __cxa_demangle() call was leaking the demangled name buffer (Confirmed by valgrind). If I understood the __cxa_demangle() docs right, the issue was that you were mixing the two operating modes (User buffer vs __cxa_demangle() allocated buffer). You passed a garbage pointer to __cxa_demangle(), which expects null or a pointer to a malloc() allocated block of *size* bytes. Note also size is 0 in your implementation. Basically the leak comes from __cxa_demangle() doing a realloc() on your garbage pointer. The fix is as simple as telling __cxa_demangle() to allocate the buffer itself. Just for reference, here is the __cxa_demangle() documentation explaining this behavior: https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.3/a01696.html