<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Troy,<div>In VerseKey::checkBounds()</div><div><div>void VerseKey::checkBounds() {</div><div><br></div><div> long i = getIndex();</div><div><br></div><div> initBounds();</div><div> if (i > upperBound) {</div><div> setIndex(upperBound);</div><div> i = getIndex();</div><div> error = KEYERR_OUTOFBOUNDS;</div><div> }</div><div> if (i < lowerBound) {</div><div> setIndex(lowerBound);</div><div> error = KEYERR_OUTOFBOUNDS;</div><div> }</div><div>}</div><div><br></div><div>i, upperBound and lowerBound are all -1, when working with a chapter that is not in the book. This is good. The proc getIndex() can’t compute the index since the chapter is not known so it rightfully returns -1.</div><div><br></div><div>I think there should be a check in here like there is in VerseKey.setIndex(int iindex).</div><div><br></div><div>So</div><div><div>void VerseKey::checkBounds() {</div><div><br></div><div> long i = getIndex();</div><div><br></div><div><b> // assert we're sane</b></div><div><b> if (i < 0) {</b></div><div><b> error = KEYERR_OUTOFBOUNDS;</b></div><div><b> return;</b></div><div><b> }</b></div></div><div><br></div><div><div> initBounds();</div><div> if (i > upperBound) {</div><div> setIndex(upperBound);</div><div> i = getIndex();</div><div> error = KEYERR_OUTOFBOUNDS;</div><div> }</div><div> if (i < lowerBound) {</div><div> setIndex(lowerBound);</div><div> error = KEYERR_OUTOFBOUNDS;</div><div> }</div><div>}</div><div><br></div><div>What do you think?</div><div><br></div><div>DM</div><div><br></div><blockquote type="cite"><div>On Jun 15, 2025, at 8:11 AM, DM Smith <dmsmith@crosswire.org> wrote:</div><br class="Apple-interchange-newline"><div><div>Troy,<br><br>I’ve narrowed it down to turning Auto Normalize off.<br><br>In examples/cmdline/parseverselist.cpp, add parser.setAutoNormalize(false) to see the error with Gen.51.1. Note Gen.50.99 (last chapter with bad verse number) works.<br><br>DM<br><br><blockquote type="cite">On Jun 12, 2025, at 7:03 PM, DM Smith <dmsmith@crosswire.org> wrote:<br><br>Troy,<br><br>I’m working on an infinite loop bug in osis2mod.<br><br>I’ve narrowed it down to ListKey containing a verse with a chapter which is beyond the end of a book.<br><br>When this happens list.increment(1) never sets an error.<br><br>Simplest test case (bit incomplete):<br><br>int i = 0;<br>ListKey list = new ListKey();<br>list.add(“Gen.51.1”);<br>for (list = TOP; !list.popError(); list.increment(1)) {<br><span class="Apple-tab-span" style="white-space:pre"> </span>if (i++ > 5) break;<br><span class="Apple-tab-span" style="white-space:pre"> </span>cout << i << list << endl;<br>}<br><br>If I change the verse reference to Gen.1.99 (valid chapter, invalid verse), it works as expected.<br><br>Can you figure out the problem?<br><br>I’ve got a work around but I’d rather not do that.<br><br>Thanks,<br><span class="Apple-tab-span" style="white-space:pre"> </span>DM<br><br>_______________________________________________<br>sword-devel mailing list: sword-devel@crosswire.org<br>http://crosswire.org/mailman/listinfo/sword-devel<br>Instructions to unsubscribe/change your settings at above page<br></blockquote><br>_______________________________________________<br>sword-devel mailing list: sword-devel@crosswire.org<br>http://crosswire.org/mailman/listinfo/sword-devel<br>Instructions to unsubscribe/change your settings at above page<br></div></div></blockquote></div><br></div></body></html>