-/* $OpenBSD: fastfind.c,v 1.13 2015/10/23 07:57:03 tedu Exp $ */
+/* $OpenBSD: fastfind.c,v 1.14 2017/12/08 17:26:42 millert Exp $ */
/*
* Copyright (c) 1995 Wolfram Schneider <wosch@FreeBSD.org>. Berlin.
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: fastfind.c,v 1.13 2015/10/23 07:57:03 tedu Exp $
+ * $Id: fastfind.c,v 1.14 2017/12/08 17:26:42 millert Exp $
*/
#ifndef _LOCATE_STATISTIC_
/* go forward or backward */
if (c == SWITCH) { /* big step, an integer */
+ if (len < INTSIZE)
+ break;
count += getwm(paddr) - OFFSET;
len -= INTSIZE; paddr += INTSIZE;
} else { /* slow step, =< 14 chars */
p = path + count;
foundchar = p - 1;
- for (;;) {
+ for (; len > 0; ) {
c = (u_char)*paddr++;
len--;
/*
*/
if (c < PARITY) {
if (c <= UMLAUT) {
- if (c == UMLAUT) {
+ if (c == UMLAUT && len > 0) {
c = (u_char)*paddr++;
len--;