$OpenBSD: patch-edit_c,v 1.1 2008/02/11 21:51:32 naddy Exp $
--- edit.c.orig	Thu Jan 24 22:07:49 2008
+++ edit.c	Thu Jan 24 22:15:39 2008
@@ -290,12 +290,18 @@ do_ft(ch, flag)
 	PTR		ptr;
 
 	switch (ch) {
-		case 1:		beep();
-					return NULL;					/* no previous command */
-		case -1:	if (chp == 'f' || chp == 't') dir = BACKWARD;
+		case -1:	if (chp == 1) {					/* no previous command */
+						beep();
+						return NULL;
+					}
+					if (chp == 'f' || chp == 't') dir = BACKWARD;
 						else dir = FORWARD;
 					break;						/* same again */
-		case 0:		if (chp == 'f' || chp == 't') dir = FORWARD;
+		case 0:		if (chp == 1) {                 /* no previous command */
+						beep();
+						return NULL;
+					}
+					if (chp == 'f' || chp == 't') dir = FORWARD;
 						else dir = BACKWARD;
 					break;						/* same again */
 		default:	chp = ch;
@@ -324,7 +330,7 @@ do_ft(ch, flag)
 			if (ptr < mem) break;
 		}
 	} while (--precount > 0);
-	if (*ptr == chi) {
+	if (ptr >= mem && ptr <= maxpos) {
 		if (loc == HEX) toggle();
 		if (chp == 't') ptr--;
 		if (chp == 'T') ptr++;
