]> source.dussan.org Git - poi.git/commitdiff
Fix NPOIFS to handle dodgy excel-95 file from bug #46904
authorNick Burch <nick@apache.org>
Tue, 26 May 2015 13:46:20 +0000 (13:46 +0000)
committerNick Burch <nick@apache.org>
Tue, 26 May 2015 13:46:20 +0000 (13:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1681756 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/poifs/filesystem/NPOIFSFileSystem.java
src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

index 4ad5c0a5b1c32cab0154212a00bef52ab2ed402b..bb5b3a50ed42424fa99c45e489ac602ef32133af 100644 (file)
@@ -436,7 +436,7 @@ public class NPOIFSFileSystem extends BlockStore
        List<BATBlock> sbats = new ArrayList<BATBlock>();
        _mini_store     = new NPOIFSMiniStore(this, _property_table.getRoot(), sbats, _header);
        nextAt = _header.getSBATStart();
-       for(int i=0; i<_header.getSBATCount(); i++) {
+       for(int i=0; i<_header.getSBATCount() && nextAt != POIFSConstants.END_OF_CHAIN; i++) {
           loopDetector.claim(nextAt);
           ByteBuffer fatData = getBlockAt(nextAt);
           sfat = BATBlock.createBATBlock(bigBlockSize, fatData);
index 36f397c01eb76565a003198881fb73f2f0c52ce4..df470f26cfb9d722153c8acfbf588bbcbb8001b8 100644 (file)
@@ -1578,8 +1578,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
                     "The supplied spreadsheet seems to be Excel"
             ));
         }
-        // TODO Fix this to work with NPOIFS as well
-/*
         try {
             NPOIFSFileSystem fs = new NPOIFSFileSystem(
                     HSSFITestDataProvider.instance.openWorkbookStream("46904.xls"));
@@ -1590,7 +1588,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
                     "The supplied spreadsheet seems to be Excel"
             ));
         }
-*/
     }
 
     /**