url-mode: regex: don't try to NULL-terminate an invalid vline

This commit is contained in:
Daniel Eklöf 2025-02-10 13:09:07 +01:00
parent 970d95c5a1
commit c63202ee0e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -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];