]> granicus.if.org Git - clang/commitdiff
Sanity checks in SourceManager::getFileEntryForID() and SourceManager::getFileEntryFo...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 5 Jan 2012 00:19:03 +0000 (00:19 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 5 Jan 2012 00:19:03 +0000 (00:19 +0000)
to make sure we do not crash. rdar://10594186

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

include/clang/Basic/SourceManager.h

index 375aea0ee902d911f2dac1278382fc225ef785f7..d08d5368d15b9fcc4aefd4ce44046e5389284ede 100644 (file)
@@ -750,13 +750,19 @@ public:
     if (MyInvalid || !Entry.isFile())
       return 0;
 
-    return Entry.getFile().getContentCache()->OrigEntry;
+    const SrcMgr::ContentCache *Content = Entry.getFile().getContentCache();
+    if (!Content)
+      return 0;
+    return Content->OrigEntry;
   }
 
   /// Returns the FileEntry record for the provided SLocEntry.
   const FileEntry *getFileEntryForSLocEntry(const SrcMgr::SLocEntry &sloc) const
   {
-    return sloc.getFile().getContentCache()->OrigEntry;
+    const SrcMgr::ContentCache *Content = sloc.getFile().getContentCache();
+    if (!Content)
+      return 0;
+    return Content->OrigEntry;
   }
 
   /// getBufferData - Return a StringRef to the source buffer data for the