mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.0.1468: illegal memory access in del_bytes()
Problem: Illegal memory access in del_bytes(). Solution: Check for negative byte count. (Christian Brabandt, closes #2466)
This commit is contained in:
@@ -761,7 +761,7 @@ emsgn(char_u *s, long n)
|
|||||||
void
|
void
|
||||||
iemsg(char_u *s)
|
iemsg(char_u *s)
|
||||||
{
|
{
|
||||||
msg(s);
|
emsg(s);
|
||||||
#ifdef ABORT_ON_INTERNAL_ERROR
|
#ifdef ABORT_ON_INTERNAL_ERROR
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
|
17
src/misc1.c
17
src/misc1.c
@@ -2457,7 +2457,7 @@ del_chars(long count, int fixpos)
|
|||||||
* If "fixpos" is TRUE, don't leave the cursor on the NUL after the line.
|
* If "fixpos" is TRUE, don't leave the cursor on the NUL after the line.
|
||||||
* Caller must have prepared for undo.
|
* Caller must have prepared for undo.
|
||||||
*
|
*
|
||||||
* return FAIL for failure, OK otherwise
|
* Return FAIL for failure, OK otherwise.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
del_bytes(
|
del_bytes(
|
||||||
@@ -2476,12 +2476,21 @@ del_bytes(
|
|||||||
oldp = ml_get(lnum);
|
oldp = ml_get(lnum);
|
||||||
oldlen = (int)STRLEN(oldp);
|
oldlen = (int)STRLEN(oldp);
|
||||||
|
|
||||||
/*
|
/* Can't do anything when the cursor is on the NUL after the line. */
|
||||||
* Can't do anything when the cursor is on the NUL after the line.
|
|
||||||
*/
|
|
||||||
if (col >= oldlen)
|
if (col >= oldlen)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
|
/* If "count" is zero there is nothing to do. */
|
||||||
|
if (count == 0)
|
||||||
|
return OK;
|
||||||
|
|
||||||
|
/* If "count" is negative the caller must be doing something wrong. */
|
||||||
|
if (count < 1)
|
||||||
|
{
|
||||||
|
IEMSGN("E950: Invalid count for del_bytes(): %ld", count);
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
/* If 'delcombine' is set and deleting (less than) one character, only
|
/* If 'delcombine' is set and deleting (less than) one character, only
|
||||||
* delete the last combining character. */
|
* delete the last combining character. */
|
||||||
|
@@ -771,6 +771,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1468,
|
||||||
/**/
|
/**/
|
||||||
1467,
|
1467,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user