[Beignet] [PATCH 2/5] Backend: Fix memleak form abi::__cxa_demangle

Xiuli Pan xiuli.pan at intel.com
Thu May 5 06:42:16 UTC 2016


From: Pan Xiuli <xiuli.pan at intel.com>

We need to free what we get from abi::__cxa_demangle

Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
 backend/src/llvm/llvm_gen_backend.hpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/backend/src/llvm/llvm_gen_backend.hpp b/backend/src/llvm/llvm_gen_backend.hpp
index 23688f5..f2a278e 100644
--- a/backend/src/llvm/llvm_gen_backend.hpp
+++ b/backend/src/llvm/llvm_gen_backend.hpp
@@ -83,12 +83,13 @@ namespace gbe
 
       if (it == map.end()) {
         int status;
-        const char *realName = abi::__cxa_demangle(symbol.c_str(), NULL, NULL, &status);
+        char *realName = abi::__cxa_demangle(symbol.c_str(), NULL, NULL, &status);
         if (status == 0) {
           std::string realFnName(realName), stripName;
           stripName = realFnName.substr(0, realFnName.find("("));
           it = map.find(stripName);
         }
+        free(realName);
       }
       // FIXME, should create a complete error reporting mechanism
       // when found error in beignet managed passes including Gen pass.
-- 
2.5.0



More information about the Beignet mailing list