aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-03-18 14:40:27 +0000
committerNick Burch <nick@apache.org>2014-03-18 14:40:27 +0000
commitdb9ad3990d810efde45d28222502511eefd4c614 (patch)
tree168d8a248cfc77b132e73afdd4889fb10a758ed4
parentf333bf18c86bc934487b750d89fdb4d4d1ab2524 (diff)
downloadpoi-db9ad3990d810efde45d28222502511eefd4c614.tar.gz
poi-db9ad3990d810efde45d28222502511eefd4c614.zip
Avoid an IndexOutOfBoundsException if there are no property nodes when searching for the start index, return -1 instead
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1578929 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
index 5b2c3f9de2..01458ac744 100644
--- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
+++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
@@ -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;