diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2008-04-15 02:49:03 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2008-04-15 02:49:03 +0000 |
commit | a341781aa419d9b6eec105dc8a5d59ff52138e41 (patch) | |
tree | b28efc336e161da3351704cee54d37d3fa25c9b2 | |
parent | 5ed9b04c403f5cc8f7316523b4f5a5b64b9e4419 (diff) | |
download | jackcess-a341781aa419d9b6eec105dc8a5d59ff52138e41.tar.gz jackcess-a341781aa419d9b6eec105dc8a5d59ff52138e41.zip |
put entry validation inline with entry reading
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@326 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/Index.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Index.java b/src/java/com/healthmarketscience/jackcess/Index.java index 9eb3ca1..ec3629d 100644 --- a/src/java/com/healthmarketscience/jackcess/Index.java +++ b/src/java/com/healthmarketscience/jackcess/Index.java @@ -806,6 +806,7 @@ public abstract class Index implements Comparable<Index> { TempBufferHolder.newHolder(TempBufferHolder.Type.HARD, true, ByteOrder.BIG_ENDIAN); + Entry prevEntry = FIRST_ENTRY; for (int i = 0; i < entryMaskLength; i++) { byte entryMask = buffer.get(entryMaskPos + i); for (int j = 0; j < 8; j++) { @@ -823,8 +824,14 @@ public abstract class Index implements Comparable<Index> { curEntryLen += entryPrefix.length; } totalEntrySize += curEntryLen; + + Entry entry = newEntry(curEntryBuffer, curEntryLen, isLeaf); + if(prevEntry.compareTo(entry) >= 0) { + throw new IOException("Unexpected order in index entries, " + + prevEntry + " >= " + entry); + } - entries.add(newEntry(curEntryBuffer, curEntryLen, isLeaf)); + entries.add(entry); if(entries.size() == 1) { if(entryPrefixLength > 0) { @@ -836,19 +843,10 @@ public abstract class Index implements Comparable<Index> { } lastStart += length; + prevEntry = entry; } } } - - // check the entry order, just to be safe - for(int i = 0; i < (entries.size() - 1); ++i) { - Entry e1 = entries.get(i); - Entry e2 = entries.get(i + 1); - if(e1.compareTo(e2) > 0) { - throw new IOException("Unexpected order in index entries, " + - e1 + " is greater than " + e2); - } - } dataPage.setEntryPrefix(entryPrefix != null ? entryPrefix : EMPTY_PREFIX); dataPage.setEntries(entries); |