Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Recoskie2007-06-05 16:11:06 -0400
committerChris Recoskie2007-06-05 16:11:06 -0400
commita7a4df6972b802eddf1e1a40475bfc01ef330c48 (patch)
tree4d64fa6df77735ecd50fea8fd2b8cb5c7215c846
parent3349dac957e75956710a2df64c89e27af5a9f64a (diff)
downloadorg.eclipse.cdt-a7a4df6972b802eddf1e1a40475bfc01ef330c48.tar.gz
org.eclipse.cdt-a7a4df6972b802eddf1e1a40475bfc01ef330c48.tar.xz
org.eclipse.cdt-a7a4df6972b802eddf1e1a40475bfc01ef330c48.zip
fix for 191091 by Jason Montojo
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java26
1 files changed, 23 insertions, 3 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java
index df8d7f32325..e69f6081e62 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java
@@ -146,6 +146,13 @@ abstract class BaseScanner implements IScanner {
final static protected int BRANCH_END = 4;
+ // Bug 191091:
+ // Conditional circular inclusions appear on the stack no more than
+ // two times. The second time it's included, if there is an include guard
+ // present, it won't be included a third time. Otherwise, we can assume
+ // it is genuinely circularly included.
+ private static final int MAX_INCLUDE_OCCURRENCES = 2;
+
// Utility
protected static String[] EMPTY_STRING_ARRAY = new String[0];
@@ -1379,18 +1386,31 @@ abstract class BaseScanner implements IScanner {
}
protected boolean isCircularInclusion(InclusionData data) {
+ // Bug 191091:
+ // We need to check for inclusions that can put the scanner into
+ // an infinite loop. So we'll need to ensure we don't count
+ // conditional circular inclusions since they're not
+ // genuinely circular.
+
+ int occurrences = 0;
for (int i = 0; i < bufferStackPos; ++i) {
- if (bufferData[i] instanceof CodeReader
+ if (bufferData[i] instanceof CodeReader
&& CharArrayUtils.equals(
((CodeReader) bufferData[i]).filename,
data.reader.filename)) {
- return true;
+ occurrences++;
+ if (occurrences > MAX_INCLUDE_OCCURRENCES) {
+ return true;
+ }
} else if (bufferData[i] instanceof InclusionData
&& CharArrayUtils
.equals(
((InclusionData) bufferData[i]).reader.filename,
data.reader.filename)) {
- return true;
+ occurrences++;
+ if (occurrences > MAX_INCLUDE_OCCURRENCES) {
+ return true;
+ }
}
}
return false;

Back to the top