From 9b6bf64760232c94149704572f16f1522eab6013 Mon Sep 17 00:00:00 2001 From: Maxim Valyanskiy Date: Fri, 9 Jul 2010 13:30:43 +0000 Subject: [PATCH] hwpf: Range.findRange fix for out-of-range searches git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@962520 13f79535-47bb-0310-9956-ffa450edef68 --- src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java | 5 +++++ 1 file changed, 5 insertions(+) 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 d2f9332a50..4d78ca9ba3 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java @@ -962,11 +962,16 @@ public class Range { // TODO -instantiable superclass private int[] findRange(List rpl, int min, int start, int end) { int x = min; PropertyNode node = (PropertyNode) rpl.get(x); + while (node.getEnd() <= start && x < rpl.size() - 1) { x++; node = (PropertyNode) rpl.get(x); } + if (node.getStart()>end) { + return new int[] {0, 0}; + } + if (node.getEnd() <= start) { return new int[] { rpl.size(), rpl.size() }; } -- 2.39.5