$NetBSD: patch-ae,v 1.5 2025/10/26 19:16:53 vins Exp $

--- lookup.c.orig	Thu Apr 14 21:25:52 2005
+++ lookup.c
@@ -247,11 +247,11 @@ int linit ()
 	    if (dp->word == (unsigned char *) -1)
 		dp->word = NULL;
 	    else
-		dp->word = &hashstrings[(unsigned long) dp->word];
+		dp->word = &hashstrings[(PTRSIZE) dp->word];
 	    if (dp->next == (struct dent *) -1)
 		dp->next = NULL;
 	    else
-		dp->next = &hashtbl[(unsigned long) dp->next];
+		dp->next = &hashtbl[(PTRSIZE) dp->next];
 	    }
 	}
 
@@ -259,12 +259,12 @@ int linit ()
 	{
 	if (entry->stripl)
 	    entry->strip =
-	      (ichar_t *) &hashstrings[(unsigned long) entry->strip];
+	      (ichar_t *) &hashstrings[(PTRSIZE) entry->strip];
 	else
 	    entry->strip = NULL;
 	if (entry->affl)
 	    entry->affix =
-	      (ichar_t *) &hashstrings[(unsigned long) entry->affix];
+	      (ichar_t *) &hashstrings[(PTRSIZE) entry->affix];
 	else
 	    entry->affix = NULL;
 	}
@@ -531,7 +531,7 @@ struct dent * lookup (s, dotree)
 	if (s1  &&  s1[0] == schar[0]
 	  &&  strcmp ((char *) s1 + 1, (char *) schar + 1) == 0)
 	    return dp;
-	while (dp->flagfield & MOREVARIANTS)	/* Skip variations */
+	while ((dp->flagfield & MOREVARIANTS) && dp->next != NULL)	/* Skip variations */
 	    dp = dp->next;
 	}
     if (dotree)
