fix(pum): fix heap-buffer-overflow with 'rightleft' (#33146)

This commit is contained in:
zeertzjq
2025-03-29 10:07:14 +08:00
committed by GitHub
parent cb31663663
commit 2681e1fce3
2 changed files with 218 additions and 31 deletions

View File

@@ -686,13 +686,13 @@ void pum_redraw(void)
char *rt_start = rt;
int cells = vim_strsize(rt);
if (cells > pum_width) {
if (grid_col - cells < col_off - pum_width) {
do {
cells -= utf_ptr2cells(rt);
MB_PTR_ADV(rt);
} while (cells > pum_width);
} while (grid_col - cells < col_off - pum_width);
if (cells < pum_width) {
if (grid_col - cells > col_off - pum_width) {
// Most left character requires 2-cells but only 1 cell is available on
// screen. Put a '<' on the left of the pum item.
*(--rt) = '<';