[Beignet] [PATCH] Backend: Fix double free of the cloned_module

Xiuli Pan xiuli.pan at intel.com
Thu Jun 15 08:45:42 UTC 2017


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

In the llvmToGen function the module will be deleted, we only need to
delete the cloned_module when the first llvmToGen success.

Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
 backend/src/backend/program.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/backend/src/backend/program.cpp b/backend/src/backend/program.cpp
index 724058c..8fb33c4 100644
--- a/backend/src/backend/program.cpp
+++ b/backend/src/backend/program.cpp
@@ -154,7 +154,12 @@ namespace gbe {
         //suppose file exists and llvmToGen will not return false.
         llvmToGen(*unit, fileName, module, 0, strictMath, OCL_PROFILING_LOG, error);
       }
+    } else {
+      if(cloned_module){
+        delete (llvm::Module*) cloned_module;
+      }
     }
+
     if(unit->getValid()){
       std::string error2;
       if (this->buildFromUnit(*unit, error2)){
@@ -163,9 +168,6 @@ namespace gbe {
       error = error + error2;
     }
     delete unit;
-    if(cloned_module){
-      delete (llvm::Module*) cloned_module;
-    }
     return ret;
   }
 
-- 
2.7.4



More information about the Beignet mailing list