From c63202ee0ee45182ec5ab440262e63b85104e59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Mon, 10 Feb 2025 13:09:07 +0100 Subject: [PATCH] url-mode: regex: don't try to NULL-terminate an invalid vline --- url-mode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/url-mode.c b/url-mode.c index 00d38d75..f04550f8 100644 --- a/url-mode.c +++ b/url-mode.c @@ -389,8 +389,11 @@ regex_detected(const struct terminal *term, enum url_action action, } /* Terminate the last line, if necessary */ - if (vline->len > 0 && vline->utf8[vline->len - 1] != '\0') + if (vline_idx < ALEN(vlines) && + vline->len > 0 && vline->utf8[vline->len - 1] != '\0') + { vline->utf8[vline->len++] = '\0'; + } for (size_t i = 0; i < ALEN(vlines); i++) { const struct vline *v = &vlines[i];