Skip to content

Commit 80c3fd7

Browse files
committed
patch 7.4.2360
Problem: Invalid memory access when formatting. (Dominique Pelle) Solution: Make sure cursor line and column are associated.
1 parent 26fe0d5 commit 80c3fd7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/misc1.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6097,7 +6097,7 @@ cin_isterminated(
60976097
* When a line ends in a comma we continue looking in the next line.
60986098
* "sp" points to a string with the line. When looking at other lines it must
60996099
* be restored to the line. When it's NULL fetch lines here.
6100-
* "lnum" is where we start looking.
6100+
* "first_lnum" is where we start looking.
61016101
* "min_lnum" is the line before which we will not be looking.
61026102
*/
61036103
static int
@@ -6108,6 +6108,7 @@ cin_isfuncdecl(
61086108
{
61096109
char_u *s;
61106110
linenr_T lnum = first_lnum;
6111+
linenr_T save_lnum = curwin->w_cursor.lnum;
61116112
int retval = FALSE;
61126113
pos_T *trypos;
61136114
int just_started = TRUE;
@@ -6117,15 +6118,20 @@ cin_isfuncdecl(
61176118
else
61186119
s = *sp;
61196120

6121+
curwin->w_cursor.lnum = lnum;
61206122
if (find_last_paren(s, '(', ')')
61216123
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL)
61226124
{
61236125
lnum = trypos->lnum;
61246126
if (lnum < min_lnum)
6127+
{
6128+
curwin->w_cursor.lnum = save_lnum;
61256129
return FALSE;
6130+
}
61266131

61276132
s = ml_get(lnum);
61286133
}
6134+
curwin->w_cursor.lnum = save_lnum;
61296135

61306136
/* Ignore line starting with #. */
61316137
if (cin_ispreproc(s))
@@ -6681,7 +6687,7 @@ find_start_brace(void) /* XXX */
66816687
static pos_T *
66826688
find_match_paren(int ind_maxparen) /* XXX */
66836689
{
6684-
return find_match_char('(', ind_maxparen);
6690+
return find_match_char('(', ind_maxparen);
66856691
}
66866692

66876693
static pos_T *

src/version.c

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

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2360,
766768
/**/
767769
2359,
768770
/**/

0 commit comments

Comments
 (0)