]> source.dussan.org Git - jackcess.git/commitdiff
Ignore invalid column usage map definitions, fixes issue 97
authorJames Ahlborn <jtahlborn@yahoo.com>
Sat, 14 Sep 2013 13:20:39 +0000 (13:20 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Sat, 14 Sep 2013 13:20:39 +0000 (13:20 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@800 f203690c-595d-4dc9-a70b-905162fa7fd2

src/changes/changes.xml
src/main/java/com/healthmarketscience/jackcess/impl/TableImpl.java
src/main/java/com/healthmarketscience/jackcess/impl/UsageMap.java

index a4a33f486b0a19b4912bd33c5216d5e7902f709a..94a241daf59b8c756be4dbd1ae79a14b41555ad1 100644 (file)
@@ -8,6 +8,9 @@
       <action dev="jahlborn" type="add">
         Add initial support for creating/parsing ole content.
       </action>
+      <action dev="jahlborn" type="fix" system="SourceForge2" issue="97">
+        Ignore invalid column usage map definitions.
+      </action>
     </release>
     <release version="2.0.0" date="2013-08-26">
       <action dev="jahlborn" type="update">
         for more details.
       </action>
     </release>
+    <release version="1.2.14.3" date="TBD">
+      <action dev="jahlborn" type="fix" system="SourceForge2" issue="97">
+        Ignore invalid column usage map definitions.
+      </action>
+    </release>    
     <release version="1.2.14.2" date="2013-08-25">
       <action dev="jahlborn" type="fix" system="SourceForge2" issue="96">
         Fix reading of Properties with multiple value blocks.
index 4cd33650cc3b787a1f0b596b945e546a994af3e3..240ebf675365ba8f1e45d6a618cf2b4bade51ed1 100644 (file)
@@ -48,7 +48,6 @@ import com.healthmarketscience.jackcess.Column;
 import com.healthmarketscience.jackcess.ColumnBuilder;
 import com.healthmarketscience.jackcess.CursorBuilder;
 import com.healthmarketscience.jackcess.DataType;
-import com.healthmarketscience.jackcess.Index;
 import com.healthmarketscience.jackcess.IndexBuilder;
 import com.healthmarketscience.jackcess.PropertyMap;
 import com.healthmarketscience.jackcess.Row;
@@ -270,11 +269,21 @@ public class TableImpl implements Table
         break;
       }
       
-      UsageMap colOwnedPages = UsageMap.read(
-          getDatabase(), tableBuffer, false);
-      UsageMap colFreeSpacePages = UsageMap.read(
-          getDatabase(), tableBuffer, false);
-    
+      int pos = tableBuffer.position();
+      UsageMap colOwnedPages = null;
+      UsageMap colFreeSpacePages = null;
+      try {
+        colOwnedPages = UsageMap.read(getDatabase(), tableBuffer, false);
+        colFreeSpacePages = UsageMap.read(getDatabase(), tableBuffer, false);
+      } catch(IllegalStateException e) {
+        // ignore invalid usage map info
+        colOwnedPages = null;
+        colFreeSpacePages = null;
+        tableBuffer.position(pos + 8);
+        LOG.warn("Table " + _name + " invalid column " + umapColNum + 
+                 " usage map definition: " + e);
+      }
+      
       for(ColumnImpl col : _columns) {
         if(col.getColumnNumber() == umapColNum) {
           col.setUsageMaps(colOwnedPages, colFreeSpacePages);
index 91695824d70158d6ffb45a964006a7fe9e251376..ac49c441ab8675d9766de7dd4cde83f5b942efd2 100644 (file)
@@ -134,6 +134,11 @@ public class UsageMap
                               int rowNum, boolean assumeOutOfRangeBitsOn)
     throws IOException
   {
+    if(pageNum <= 0) {
+      // usage maps will never appear on page 0 (or less)
+      throw new IllegalStateException("Invalid usage map page number " + pageNum);
+    }
+
     JetFormat format = database.getFormat();
     PageChannel pageChannel = database.getPageChannel();
     ByteBuffer tableBuffer = pageChannel.createPageBuffer();