summaryrefslogtreecommitdiff
path: root/tools/libclang/CIndexHigh.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-10 02:36:25 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2011-12-10 02:36:25 +0000
commit16ed0e6fda74800595cb98d11969fc4afcc00bac (patch)
tree08fc4e6cf31d879b1bc3e2c954cfa19f2467313d /tools/libclang/CIndexHigh.cpp
parenta4288c4aa05075cd45fd4de61d95ffe920fe6441 (diff)
downloadclang-16ed0e6fda74800595cb98d11969fc4afcc00bac.tar.gz
[libclang] Add defensive checks to make sure we don't try to dereference
a null pointer after getCursorDecl() is called. rdar://10298421. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146312 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CIndexHigh.cpp')
-rw-r--r--tools/libclang/CIndexHigh.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/libclang/CIndexHigh.cpp b/tools/libclang/CIndexHigh.cpp
index 4eabefb925..ec76898cc8 100644
--- a/tools/libclang/CIndexHigh.cpp
+++ b/tools/libclang/CIndexHigh.cpp
@@ -21,6 +21,8 @@ using namespace cxcursor;
static void getTopOverriddenMethods(CXTranslationUnit TU,
Decl *D,
SmallVectorImpl<Decl *> &Methods) {
+ if (!D)
+ return;
if (!isa<ObjCMethodDecl>(D) && !isa<CXXMethodDecl>(D))
return;
@@ -147,6 +149,9 @@ static enum CXChildVisitResult findFileIdRefVisit(CXCursor cursor,
return CXChildVisit_Recurse;
Decl *D = cxcursor::getCursorDecl(declCursor);
+ if (!D)
+ return CXChildVisit_Continue;
+
FindFileIdRefVisitData *data = (FindFileIdRefVisitData *)client_data;
if (data->isHit(D)) {
cursor = cxcursor::getSelectorIdentifierCursor(data->SelectorIdIdx, cursor);