GBE: Fix a potential segfault.
authorZhigang Gong <zhigang.gong@intel.com>
Thu, 11 Sep 2014 05:44:16 +0000 (13:44 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Thu, 11 Sep 2014 05:46:21 +0000 (13:46 +0800)
And when we fail to compile a module, the fileName may be NULL, we can't
access it unconditionally.

Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
backend/src/backend/program.cpp

index cc76493..bd194a7 100644 (file)
@@ -114,7 +114,8 @@ namespace gbe {
       cloned_module = llvm::CloneModule((llvm::Module*)module);
     }
     if (llvmToGen(*unit, fileName, module, optLevel, OCL_STRICT_CONFORMANCE) == false) {
-      error = std::string(fileName) + " not found";
+      if (fileName)
+        error = std::string(fileName) + " not found";
       return false;
     }
     //If unit is not valid, maybe some thing don't support by backend, introduce by some passes