Comparing std::string with NULL is a bad idea, so just check whether its empty.
authorTorok Edwin <edwintorok@gmail.com>
Thu, 10 Dec 2009 10:01:47 +0000 (10:01 +0000)
committerTorok Edwin <edwintorok@gmail.com>
Thu, 10 Dec 2009 10:01:47 +0000 (10:01 +0000)
This code was crashing always with oprofile enabled, since it tried to create a StringRef
out of NULL, which run strlen on NULL.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91046 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp

index 076e5a0ce7b568e67f6dd6dd10dc651667a3e649..52a8f71ca34bc1d03b4687206f732cad1db33fec 100644 (file)
@@ -76,7 +76,7 @@ class FilenameCache {
  public:
   const char *getFilename(MDNode *Scope) {
     std::string &Filename = Filenames[Scope];
-    if (Filename == NULL) {
+    if (Filename.empty()) {
       DIScope S(Scope);
       Filename = S.getFilename();
     }