summaryrefslogtreecommitdiff
path: root/tools/libclang/CIndexUSRs.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/CIndexUSRs.cpp
parenta4288c4aa05075cd45fd4de61d95ffe920fe6441 (diff)
downloadclang-16ed0e6fda74800595cb98d11969fc4afcc00bac.tar.gz
clang-16ed0e6fda74800595cb98d11969fc4afcc00bac.tar.bz2
clang-16ed0e6fda74800595cb98d11969fc4afcc00bac.tar.xz
[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/CIndexUSRs.cpp')
-rw-r--r--tools/libclang/CIndexUSRs.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp
index 32c4db6abe..40d4fb1c69 100644
--- a/tools/libclang/CIndexUSRs.cpp
+++ b/tools/libclang/CIndexUSRs.cpp
@@ -845,6 +845,9 @@ CXString clang_getCursorUSR(CXCursor C) {
if (clang_isDeclaration(K)) {
Decl *D = cxcursor::getCursorDecl(C);
+ if (!D)
+ return createCXString("");
+
CXTranslationUnit TU = cxcursor::getCursorTU(C);
if (!TU)
return createCXString("");