From 3868a2cdc7f2457c6077445ff57ac530f7aead50 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Tue, 18 Mar 2014 14:40:27 +0000 Subject: [PATCH] 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 --- src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java | 5 +++-- 1 file 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 5b2c3f9de..01458ac74 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> rpl, int start ) { + if ( rpl.size() == 0 ) + return -1; if ( rpl.get( 0 ).getStart() >= start ) return 0;