]> source.dussan.org Git - poi.git/commitdiff
Avoid an IndexOutOfBoundsException if there are no property nodes when searching...
authorNick Burch <nick@apache.org>
Tue, 18 Mar 2014 14:40:27 +0000 (14:40 +0000)
committerNick Burch <nick@apache.org>
Tue, 18 Mar 2014 14:40:27 +0000 (14:40 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1578929 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java

index 5b2c3f9de284b7db313209c70a292ed5b25f010c..01458ac744fe8cc47d25a8073623798194517584 100644 (file)
@@ -21,8 +21,6 @@ import java.lang.ref.WeakReference;
 import java.util.List;
 import java.util.NoSuchElementException;
 
-import org.apache.poi.util.Internal;
-
 import org.apache.poi.hwpf.HWPFDocument;
 import org.apache.poi.hwpf.HWPFDocumentCore;
 import org.apache.poi.hwpf.model.CHPX;
@@ -37,6 +35,7 @@ import org.apache.poi.hwpf.model.TextPieceTable;
 import org.apache.poi.hwpf.sprm.CharacterSprmCompressor;
 import org.apache.poi.hwpf.sprm.ParagraphSprmCompressor;
 import org.apache.poi.hwpf.sprm.SprmBuffer;
+import org.apache.poi.util.Internal;
 import org.apache.poi.util.LittleEndian;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
@@ -1013,6 +1012,8 @@ public class Range { // TODO -instantiable superclass
     private static int binarySearchStart( List<? extends PropertyNode<?>> rpl,
             int start )
     {
+        if ( rpl.size() == 0 )
+            return -1;
         if ( rpl.get( 0 ).getStart() >= start )
             return 0;