[LLVMdev] [PATCH] Catch NULL return value of ExecutionEngine::create()
Eric Rannaud
eric.rannaud at gmail.com
Tue Jun 23 12:04:14 PDT 2009
ExecutionEngine::create() can return NULL with an empty error message
(admittedly, it did so because of global variable initialization
problems). The code currently lets NULL go through if ErrorMsg is empty,
and segfaults later.
When EE is NULL but ErrorMsg is empty, simply do not try to
print it and exit.
Index: tools/lli/lli.cpp
===================================================================
--- tools/lli/lli.cpp (revision 73978)
+++ tools/lli/lli.cpp (working copy)
@@ -144,8 +144,11 @@
InitializeNativeTarget();
EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl);
- if (!EE && !ErrorMsg.empty()) {
- std::cerr << argv[0] << ":error creating EE: " << ErrorMsg <<
"\n";
+ if (!EE) {
+ if (!ErrorMsg.empty())
+ std::cerr << argv[0] << ":error creating EE: " << ErrorMsg <<
"\n";
+ else
+ std::cerr << argv[0] << ":error creating EE\n";
exit(1);
}
More information about the llvm-dev
mailing list