mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.0026: accessing freed memory with diff put
Problem: Accessing freed memory with diff put. Solution: Bail out when diff pointer is no longer valid.
This commit is contained in:
24
src/diff.c
24
src/diff.c
@@ -2642,6 +2642,20 @@ nv_diffgetput(int put, long count)
|
|||||||
ex_diffgetput(&ea);
|
ex_diffgetput(&ea);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if "diff" appears in the list of diff blocks of the current tab.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
valid_diff(diff_T *diff)
|
||||||
|
{
|
||||||
|
diff_T *dp;
|
||||||
|
|
||||||
|
for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
|
||||||
|
if (dp == diff)
|
||||||
|
return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ":diffget"
|
* ":diffget"
|
||||||
* ":diffput"
|
* ":diffput"
|
||||||
@@ -2899,9 +2913,9 @@ ex_diffgetput(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust marks. This will change the following entries!
|
|
||||||
if (added != 0)
|
if (added != 0)
|
||||||
{
|
{
|
||||||
|
// Adjust marks. This will change the following entries!
|
||||||
mark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, (long)added);
|
mark_adjust(lnum, lnum + count - 1, (long)MAXLNUM, (long)added);
|
||||||
if (curwin->w_cursor.lnum >= lnum)
|
if (curwin->w_cursor.lnum >= lnum)
|
||||||
{
|
{
|
||||||
@@ -2923,7 +2937,13 @@ ex_diffgetput(exarg_T *eap)
|
|||||||
#endif
|
#endif
|
||||||
vim_free(dfree);
|
vim_free(dfree);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// mark_adjust() may have made "dp" invalid. We don't know where
|
||||||
|
// to continue then, bail out.
|
||||||
|
if (added != 0 && !valid_diff(dp))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (dfree == NULL)
|
||||||
// mark_adjust() may have changed the count in a wrong way
|
// mark_adjust() may have changed the count in a wrong way
|
||||||
dp->df_count[idx_to] = new_count;
|
dp->df_count[idx_to] = new_count;
|
||||||
|
|
||||||
|
@@ -735,6 +735,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 */
|
||||||
|
/**/
|
||||||
|
26,
|
||||||
/**/
|
/**/
|
||||||
25,
|
25,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user