diff options
-rw-r--r-- | clang/tools/CIndex/CIndex.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp index f07b94fc51d..07bb7fbd83e 100644 --- a/clang/tools/CIndex/CIndex.cpp +++ b/clang/tools/CIndex/CIndex.cpp @@ -1003,7 +1003,8 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx, // FIXME: Until we have broader testing, just drop the entire AST if we // encountered an error. if (NumErrors != Diags->getNumErrors()) { - if (CXXIdx->getDisplayDiagnostics()) { + // Make sure to check that 'Unit' is non-NULL. + if (CXXIdx->getDisplayDiagnostics() && Unit.get()) { for (ASTUnit::diag_iterator D = Unit->diag_begin(), DEnd = Unit->diag_end(); D != DEnd; ++D) { |