[cfe-commits] r97849 - /cfe/trunk/tools/CIndex/CIndex.cpp
Ted Kremenek
kremenek at apple.com
Fri Mar 5 14:43:29 PST 2010
Author: kremenek
Date: Fri Mar 5 16:43:29 2010
New Revision: 97849
URL: http://llvm.org/viewvc/llvm-project?rev=97849&view=rev
Log:
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.
Modified:
cfe/trunk/tools/CIndex/CIndex.cpp
Modified: cfe/trunk/tools/CIndex/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/CIndex/CIndex.cpp?rev=97849&r1=97848&r2=97849&view=diff
==============================================================================
--- cfe/trunk/tools/CIndex/CIndex.cpp (original)
+++ cfe/trunk/tools/CIndex/CIndex.cpp Fri Mar 5 16:43:29 2010
@@ -1003,7 +1003,8 @@
// 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) {
More information about the cfe-commits
mailing list