0
0
mirror of https://github.com/vim/vim.git synced 2025-10-06 05:44:14 -04:00

patch 8.1.0694: when using text props may free memory that is not allocated

Problem:    When using text props may free memory that is not allocated.
            (Andy Massimino)
Solution:   Allocate the line when adjusting text props. (closes #3766)
This commit is contained in:
Bram Moolenaar
2019-01-06 12:54:55 +01:00
parent f780b8a1c1
commit 4614f53e0f
2 changed files with 12 additions and 3 deletions

View File

@@ -979,7 +979,9 @@ adjust_prop_columns(
pt = text_prop_type_by_id(curbuf, tmp_prop.tp_type); pt = text_prop_type_by_id(curbuf, tmp_prop.tp_type);
if (bytes_added > 0 if (bytes_added > 0
? (tmp_prop.tp_col >= col + (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL) ? 2 : 1)) ? (tmp_prop.tp_col >= col
+ (pt != NULL && (pt->pt_flags & PT_FLAG_INS_START_INCL)
? 2 : 1))
: (tmp_prop.tp_col > col + 1)) : (tmp_prop.tp_col > col + 1))
{ {
tmp_prop.tp_col += bytes_added; tmp_prop.tp_col += bytes_added;
@@ -1001,8 +1003,13 @@ adjust_prop_columns(
} }
if (dirty) if (dirty)
{ {
colnr_T newlen = (int)textlen + wi * (colnr_T)sizeof(textprop_T);
if ((curbuf->b_ml.ml_flags & ML_LINE_DIRTY) == 0)
curbuf->b_ml.ml_line_ptr =
vim_memsave(curbuf->b_ml.ml_line_ptr, newlen);
curbuf->b_ml.ml_flags |= ML_LINE_DIRTY; curbuf->b_ml.ml_flags |= ML_LINE_DIRTY;
curbuf->b_ml.ml_line_len = (int)textlen + wi * sizeof(textprop_T); curbuf->b_ml.ml_line_len = newlen;
} }
} }

View File

@@ -799,6 +799,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 */
/**/
694,
/**/ /**/
693, 693,
/**/ /**/