From: Ted Kremenek Date: Thu, 22 Jul 2010 11:30:19 +0000 (+0000) Subject: Fix ' MakeCXCursor null dereference when body of block is... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=664cffd330611d78fc0286f539589920a37ca328;p=clang Fix ' MakeCXCursor null dereference when body of block is invalid' by checking that the body of a BlockDecl is null before constructing a CXCursor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109097 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 47c6d3ca3f..0a3d54b6cb 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -520,7 +520,10 @@ bool CursorVisitor::VisitBlockDecl(BlockDecl *B) { if (Visit(B->getSignatureAsWritten()->getTypeLoc())) return true; - return Visit(MakeCXCursor(B->getBody(), StmtParent, TU)); + if (Stmt *Body = B->getBody()) + return Visit(MakeCXCursor(Body, StmtParent, TU)); + + return false; } bool CursorVisitor::VisitDeclContext(DeclContext *DC) {