diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-03-05 22:43:29 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-03-05 22:43:29 +0000 |
commit | a6d3ab394c4cd854b5a7b600a578a7a75c69507c (patch) | |
tree | 5c44e8f97b5646192a4bd6fad697c63052979821 | |
parent | b39084072f42245e62d9d3bb9d4d599deffc3c59 (diff) | |
download | bcm5719-llvm-a6d3ab394c4cd854b5a7b600a578a7a75c69507c.tar.gz bcm5719-llvm-a6d3ab394c4cd854b5a7b600a578a7a75c69507c.zip |
Check if 'Unit' is NULL before trying to iterate over the diagnostics.
This obviates a null dereference that can occur when 'NumErrors'
is not zero.
llvm-svn: 97849
-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) { |