Skip to content

Commit 43b5d10

Browse files
brammooldouglaskayama
authored andcommitted
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().
1 parent dad106b commit 43b5d10

2 files changed

Lines changed: 16 additions & 10 deletions

File tree

src/ex_getln.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,6 +2253,9 @@ getexmodeline(promptc, cookie, indent)
22532253
got_int = FALSE;
22542254
while (!got_int)
22552255
{
2256+
long sw;
2257+
char_u *s;
2258+
22562259
if (ga_grow(&line_ga, 40) == FAIL)
22572260
break;
22582261

@@ -2304,23 +2307,22 @@ getexmodeline(promptc, cookie, indent)
23042307
msg_col = startcol;
23052308
msg_clr_eos();
23062309
line_ga.ga_len = 0;
2307-
continue;
2310+
goto redraw;
23082311
}
23092312

23102313
if (c1 == Ctrl_T)
23112314
{
2312-
long sw = get_sw_value(curbuf);
2313-
2315+
sw = get_sw_value(curbuf);
23142316
p = (char_u *)line_ga.ga_data;
23152317
p[line_ga.ga_len] = NUL;
23162318
indent = get_indent_str(p, 8, FALSE);
23172319
indent += sw - indent % sw;
23182320
add_indent:
23192321
while (get_indent_str(p, 8, FALSE) < indent)
23202322
{
2321-
char_u *s = skipwhite(p);
2322-
2323-
ga_grow(&line_ga, 1);
2323+
ga_grow(&line_ga, 2); /* one more for the NUL */
2324+
p = (char_u *)line_ga.ga_data;
2325+
s = skipwhite(p);
23242326
mch_memmove(s + 1, s, line_ga.ga_len - (s - p) + 1);
23252327
*s = ' ';
23262328
++line_ga.ga_len;
@@ -2369,13 +2371,15 @@ getexmodeline(promptc, cookie, indent)
23692371
{
23702372
p[line_ga.ga_len] = NUL;
23712373
indent = get_indent_str(p, 8, FALSE);
2372-
--indent;
2373-
indent -= indent % get_sw_value(curbuf);
2374+
if (indent > 0)
2375+
{
2376+
--indent;
2377+
indent -= indent % get_sw_value(curbuf);
2378+
}
23742379
}
23752380
while (get_indent_str(p, 8, FALSE) > indent)
23762381
{
2377-
char_u *s = skipwhite(p);
2378-
2382+
s = skipwhite(p);
23792383
mch_memmove(s - 1, s, line_ga.ga_len - (s - p) + 1);
23802384
--line_ga.ga_len;
23812385
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,8 @@ static char *(features[]) =
756756

757757
static int included_patches[] =
758758
{ /* Add new patch number below this line */
759+
/**/
760+
690,
759761
/**/
760762
689,
761763
/**/

0 commit comments

Comments
 (0)