patch 7.4.690 for Problem: Memory access errors when changing indent in Ex mode. Also missing

redraw when using CTRL-U. (Knil Ino)
Solution:   Update pointers after calling ga_grow().
This commit is contained in:
Bram Moolenaar
2015-04-03 17:11:45 +02:00
parent d87c36ea5e
commit da6365774d
2 changed files with 16 additions and 10 deletions

View File

@ -2245,6 +2245,9 @@ getexmodeline(promptc, cookie, indent)
got_int = FALSE; got_int = FALSE;
while (!got_int) while (!got_int)
{ {
long sw;
char_u *s;
if (ga_grow(&line_ga, 40) == FAIL) if (ga_grow(&line_ga, 40) == FAIL)
break; break;
@ -2296,13 +2299,12 @@ getexmodeline(promptc, cookie, indent)
msg_col = startcol; msg_col = startcol;
msg_clr_eos(); msg_clr_eos();
line_ga.ga_len = 0; line_ga.ga_len = 0;
continue; goto redraw;
} }
if (c1 == Ctrl_T) if (c1 == Ctrl_T)
{ {
long sw = get_sw_value(curbuf); sw = get_sw_value(curbuf);
p = (char_u *)line_ga.ga_data; p = (char_u *)line_ga.ga_data;
p[line_ga.ga_len] = NUL; p[line_ga.ga_len] = NUL;
indent = get_indent_str(p, 8, FALSE); indent = get_indent_str(p, 8, FALSE);
@ -2310,9 +2312,9 @@ getexmodeline(promptc, cookie, indent)
add_indent: add_indent:
while (get_indent_str(p, 8, FALSE) < indent) while (get_indent_str(p, 8, FALSE) < indent)
{ {
char_u *s = skipwhite(p); ga_grow(&line_ga, 2); /* one more for the NUL */
p = (char_u *)line_ga.ga_data;
ga_grow(&line_ga, 1); s = skipwhite(p);
mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1); mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1);
*s = ' '; *s = ' ';
++line_ga.ga_len; ++line_ga.ga_len;
@ -2361,13 +2363,15 @@ redraw:
{ {
p[line_ga.ga_len] = NUL; p[line_ga.ga_len] = NUL;
indent = get_indent_str(p, 8, FALSE); indent = get_indent_str(p, 8, FALSE);
--indent; if (indent > 0)
indent -= indent % get_sw_value(curbuf); {
--indent;
indent -= indent % get_sw_value(curbuf);
}
} }
while (get_indent_str(p, 8, FALSE) > indent) while (get_indent_str(p, 8, FALSE) > indent)
{ {
char_u *s = skipwhite(p); s = skipwhite(p);
mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1); mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1);
--line_ga.ga_len; --line_ga.ga_len;
} }

View File

@ -741,6 +741,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 */
/**/
690,
/**/ /**/
689, 689,
/**/ /**/