From 7d3a555464e1b6b4b55ea7929b95cb47f04c0efb Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Sun, 24 Jan 2021 17:03:22 +0100 Subject: [PATCH] tweaks: avoid the vague possibility of advancing beyond end-of-line Like the other two fragments that advance over a zero-length match, also this fragment should avoid the possibility of stepping beyond the end of the line. --- src/winio.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/winio.c b/src/winio.c index c65bbbc6..a16f8116 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2524,6 +2524,8 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col) /* If the match has length zero, advance over it. */ if (match.rm_so == match.rm_eo) { + if (line->data[index] == '\0') + break; index = step_right(line->data, index); continue; }