mirror of
https://github.com/neovim/neovim.git
synced 2025-09-27 13:38:34 +00:00
fix strict-overflow cases #3236
This commit is contained in:

committed by
Justin M. Keyes

parent
fc7055f6e9
commit
bbe24da869
@@ -4109,7 +4109,6 @@ check_map (
|
|||||||
int hash;
|
int hash;
|
||||||
int len, minlen;
|
int len, minlen;
|
||||||
mapblock_T *mp;
|
mapblock_T *mp;
|
||||||
char_u *s;
|
|
||||||
int local;
|
int local;
|
||||||
|
|
||||||
validate_maphash();
|
validate_maphash();
|
||||||
@@ -4133,17 +4132,14 @@ check_map (
|
|||||||
/* skip entries with wrong mode, wrong length and not matching
|
/* skip entries with wrong mode, wrong length and not matching
|
||||||
* ones */
|
* ones */
|
||||||
if ((mp->m_mode & mode) && (!exact || mp->m_keylen == len)) {
|
if ((mp->m_mode & mode) && (!exact || mp->m_keylen == len)) {
|
||||||
if (len > mp->m_keylen)
|
char_u *s = mp->m_keys;
|
||||||
minlen = mp->m_keylen;
|
int keylen = mp->m_keylen;
|
||||||
else
|
if (ign_mod && keylen >= 3
|
||||||
minlen = len;
|
&& s[0] == K_SPECIAL && s[1] == KS_MODIFIER) {
|
||||||
s = mp->m_keys;
|
|
||||||
if (ign_mod && s[0] == K_SPECIAL && s[1] == KS_MODIFIER
|
|
||||||
&& s[2] != NUL) {
|
|
||||||
s += 3;
|
s += 3;
|
||||||
if (len > mp->m_keylen - 3)
|
keylen -= 3;
|
||||||
minlen = mp->m_keylen - 3;
|
|
||||||
}
|
}
|
||||||
|
minlen = keylen < len ? keylen : len;
|
||||||
if (STRNCMP(s, keys, minlen) == 0) {
|
if (STRNCMP(s, keys, minlen) == 0) {
|
||||||
if (mp_ptr != NULL)
|
if (mp_ptr != NULL)
|
||||||
*mp_ptr = mp;
|
*mp_ptr = mp;
|
||||||
|
@@ -212,8 +212,11 @@ static void u_check(int newhead_may_be_NULL) {
|
|||||||
*/
|
*/
|
||||||
int u_save_cursor(void)
|
int u_save_cursor(void)
|
||||||
{
|
{
|
||||||
return u_save((linenr_T)(curwin->w_cursor.lnum - 1),
|
linenr_T cur = curwin->w_cursor.lnum;
|
||||||
(linenr_T)(curwin->w_cursor.lnum + 1));
|
linenr_T top = cur > 0 ? cur - 1 : 0;
|
||||||
|
linenr_T bot = cur + 1;
|
||||||
|
|
||||||
|
return u_save(top, bot);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -227,10 +230,9 @@ int u_save(linenr_T top, linenr_T bot)
|
|||||||
if (undo_off)
|
if (undo_off)
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
if (top > curbuf->b_ml.ml_line_count
|
if (top >= bot || bot > (curbuf->b_ml.ml_line_count + 1)) {
|
||||||
|| top >= bot
|
|
||||||
|| bot > curbuf->b_ml.ml_line_count + 1)
|
|
||||||
return FAIL; /* rely on caller to do error messages */
|
return FAIL; /* rely on caller to do error messages */
|
||||||
|
}
|
||||||
|
|
||||||
if (top + 2 == bot)
|
if (top + 2 == bot)
|
||||||
u_saveline((linenr_T)(top + 1));
|
u_saveline((linenr_T)(top + 1));
|
||||||
|
Reference in New Issue
Block a user