Skip to content

Commit 955f198

Browse files
committed
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Problem: Asan detects a memory error when EXITFREE is defined. (Dominique Pelle) Solution: In getvcol() check for ml_get_buf() returning an empty string. Also skip adjusting the scroll position. Set "exiting" in mch_exit() for all systems.
1 parent e971df3 commit 955f198

6 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/charset.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,10 @@ getvcol(
12961296
posptr = NULL; /* continue until the NUL */
12971297
else
12981298
{
1299+
/* Special check for an empty line, which can happen on exit, when
1300+
* ml_get_buf() always returns an empty string. */
1301+
if (*ptr == NUL)
1302+
pos->col = 0;
12991303
posptr = ptr + pos->col;
13001304
#ifdef FEAT_MBYTE
13011305
if (has_mbyte)

src/os_amiga.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,8 @@ mch_early_init(void)
889889
void
890890
mch_exit(int r)
891891
{
892+
exiting = TRUE;
893+
892894
if (raw_in) /* put terminal in 'normal' mode */
893895
{
894896
settmode(TMODE_COOK);

src/os_mswin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ int _stricoll(char *a, char *b)
201201
void
202202
mch_exit(int r)
203203
{
204+
exiting = TRUE;
205+
204206
display_errors();
205207

206208
ml_close_all(TRUE); /* remove all memfiles */

src/os_win32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2538,8 +2538,9 @@ mch_init(void)
25382538
void
25392539
mch_exit(int r)
25402540
{
2541-
stoptermcap();
2541+
exiting = TRUE;
25422542

2543+
stoptermcap();
25432544
if (g_fWindInitCalled)
25442545
settmode(TMODE_COOK);
25452546

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
307,
767769
/**/
768770
306,
769771
/**/

src/window.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5708,7 +5708,10 @@ win_new_height(win_T *wp, int height)
57085708
wp->w_height = height;
57095709
wp->w_skipcol = 0;
57105710

5711-
scroll_to_fraction(wp, prev_height);
5711+
/* There is no point in adjusting the scroll position when exiting. Some
5712+
* values might be invalid. */
5713+
if (!exiting)
5714+
scroll_to_fraction(wp, prev_height);
57125715
}
57135716

57145717
void

0 commit comments

Comments
 (0)