forked from gegelati/gegelati
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(Releng) Fix memory leak when __cxa_demangle is called
- Loading branch information
Bourgoin Thomas
committed
Jul 13, 2021
1 parent
e21b675
commit ad362ae
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "data/arrayWrapper.h" | ||
|
||
#ifdef __GNUC__ | ||
std::string demangle(const char* name) | ||
{ | ||
int status = -4; | ||
char* demangleValue = abi::__cxa_demangle(name, nullptr, nullptr, &status); | ||
std::string result; | ||
if (status == 0) { | ||
result = std::string{demangleValue}; | ||
free(demangleValue); | ||
} | ||
else { | ||
throw std::runtime_error("Error while trying to demangle the value. " | ||
"Return code of abi::__cxa_demangle is " + | ||
std::to_string(status)); | ||
} | ||
return result; | ||
} | ||
#endif |