From: Maxim Valyanskiy Date: Fri, 9 Jul 2010 13:30:43 +0000 (+0000) Subject: hwpf: Range.findRange fix for out-of-range searches X-Git-Tag: REL_3_7_BETA2~29 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9b6bf64760232c94149704572f16f1522eab6013;p=poi.git 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 --- 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() }; }