From 58b0fe72525a4dc58860a22c1d7a9555719a83ef Mon Sep 17 00:00:00 2001 From: David Schultz Date: Sat, 28 Feb 2009 06:27:23 +0000 Subject: [PATCH] Make `less -R' not crash all the time. --- contrib/less/line.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contrib/less/line.c b/contrib/less/line.c index 944e02d86963..11122a5db9fb 100644 --- a/contrib/less/line.c +++ b/contrib/less/line.c @@ -601,9 +601,11 @@ store_char(ch, a, rep, pos) { if (!is_ansi_end(ch) && !is_ansi_middle(ch)) { /* Remove whole unrecognized sequence. */ - do { + while (curr) { --curr; - } while (!IS_CSI_START(linebuf[curr])); + if (IS_CSI_START(linebuf[curr])) + break; + } return 0; } a = AT_ANSI; /* Will force re-AT_'ing around it. */