diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog index ec3883690ae..71c5a92a957 100644 --- a/core/org.eclipse.cdt.core/index/ChangeLog +++ b/core/org.eclipse.cdt.core/index/ChangeLog @@ -1,3 +1,17 @@ +2004-02-03 Alain Magloire + + Patches from Thomas Fletcher dealing with the indexer. + + - Remove assumed throw/catch of an exception to be a regular occurance + and replace with explicit test and return for bounds access to the + particular array. + + - Consider references outside of the mapping range the same as no longer + valid mappings (ie -1 entries) and avoid array range exceptions. + + * index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java + * index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java + 2004-01-26 John Camelon Updated clients to use new Scanner logging service. diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java index cf746b72478..3e9359a0f97 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/FileListBlock.java @@ -63,9 +63,12 @@ public class FileListBlock extends Block { try { String[] paths= getPaths(); int i= fileNum - field.getInt4(0); + if(i >= paths.length) { //fileNum was too large + return null; + } resp= new IndexedFile(paths[i], fileNum); } catch (Exception e) { - //fileNum too big + //Cover ourselves in case something happens getting the indexed file } return resp; } diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java index 20727388e74..3445c0c8e16 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/impl/WordEntry.java @@ -128,8 +128,12 @@ public class WordEntry { */ public void mapRefs(int[] mappings) { int position= 0; + for (int i= 0; i < fNumRefs; i++) { - int map= mappings[fRefs[i]]; + //Take care that the reference is actually within the bounds of the mapping + int map= -1; + if(fRefs[i] >= 0 && fRefs[i] < mappings.length) + map= mappings[fRefs[i]]; if (map != -1 && map != 0) fRefs[position++]= map; }