vim-patch:8.0.0883: invalid memory access with nonsensical script

Problem:    Invalid memory access with nonsensical script.
Solution:   Check "dstlen" being positive. (Dominique Pelle)
1c864093f9
This commit is contained in:
Jan Edmund Lazo 2018-08-24 19:50:55 -04:00
parent c0157e8fe0
commit cba3025c43

View File

@ -457,15 +457,18 @@ void expand_env_esc(char_u *restrict srcp,
} else if ((src[0] == ' ' || src[0] == ',') && !one) {
at_start = true;
}
if (dstlen > 0) {
*dst++ = *src++;
--dstlen;
dstlen--;
if (prefix != NULL && src - prefix_len >= srcp
if (prefix != NULL
&& src - prefix_len >= srcp
&& STRNCMP(src - prefix_len, prefix, prefix_len) == 0) {
at_start = true;
}
}
}
}
*dst = NUL;
}