vim-patch:9.0.1270: crash when using search stat in narrow screen (#22078)

Problem:    Crash when using search stat in narrow screen.
Solution:   Check length of message. (closes vim/vim#11921)

a7d36b7320
This commit is contained in:
zeertzjq
2023-02-01 08:21:32 +08:00
committed by GitHub
parent 249b9de405
commit 7880eeb2ee
2 changed files with 29 additions and 1 deletions

View File

@@ -2644,7 +2644,12 @@ static void cmdline_search_stat(int dirc, pos_T *pos, pos_T *cursor_pos, bool sh
len += 2;
}
memmove(msgbuf + strlen(msgbuf) - len, t, len);
size_t msgbuf_len = strlen(msgbuf);
if (len > msgbuf_len) {
len = msgbuf_len;
}
memmove(msgbuf + msgbuf_len - len, t, len);
if (dirc == '?' && stat.cur == maxcount + 1) {
stat.cur = -1;
}