$OpenBSD: patch-src_init2_c,v 1.2 2007/05/30 22:33:11 naddy Exp $
--- src/init2.c.orig	Sun Dec 19 06:51:30 2004
+++ src/init2.c	Wed May 30 16:25:24 2007
@@ -226,10 +226,10 @@ void configchoice(void *opt, char *cmd, char *arg1, ch
     return;
   }
 
-  if (STREQ(cmdend - 6, "SORTBY"))
+  if ((cmd <= (cmdend - 6)) && STREQ(cmdend - 6, "SORTBY"))
     choices = sortbychoices;
 #ifndef NOGRAPHICS
-  else if (STREQ(cmdend - 5, "CHART"))
+  else if ((cmd <= (cmdend - 5)) && STREQ(cmdend - 5, "CHART"))
     choices = chartchoices;
 #endif
   else if (STREQ(cmd, "OUTPUT"))
@@ -242,7 +242,7 @@ void configchoice(void *opt, char *cmd, char *arg1, ch
     choices = langchoices;
   else if (STREQ(cmd, "GOTOS"))
     choices = gotochoices;
-  else if (STREQ(cmdend - 4, "CASE")) {
+  else if ((cmd <= (cmdend - 4)) && STREQ(cmdend - 4, "CASE")) {
     choices = casechoices;
     islog = TRUE;
   }
