Skip to content

Commit

Permalink
patch 8.0.0307: asan detects a memory error when EXITFREE is defined
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brammool committed Feb 5, 2017
1 parent e971df3 commit 955f198
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/charset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,10 @@ getvcol(
posptr = NULL; /* continue until the NUL */
else
{
/* Special check for an empty line, which can happen on exit, when
* ml_get_buf() always returns an empty string. */
if (*ptr == NUL)
pos->col = 0;
posptr = ptr + pos->col;
#ifdef FEAT_MBYTE
if (has_mbyte)
Expand Down
2 changes: 2 additions & 0 deletions src/os_amiga.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,8 @@ mch_early_init(void)
void
mch_exit(int r)
{
exiting = TRUE;

if (raw_in) /* put terminal in 'normal' mode */
{
settmode(TMODE_COOK);
Expand Down
2 changes: 2 additions & 0 deletions src/os_mswin.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ int _stricoll(char *a, char *b)
void
mch_exit(int r)
{
exiting = TRUE;

display_errors();

ml_close_all(TRUE); /* remove all memfiles */
Expand Down
3 changes: 2 additions & 1 deletion src/os_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -2538,8 +2538,9 @@ mch_init(void)
void
mch_exit(int r)
{
stoptermcap();
exiting = TRUE;

stoptermcap();
if (g_fWindInitCalled)
settmode(TMODE_COOK);

Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
307,
/**/
306,
/**/
Expand Down
5 changes: 4 additions & 1 deletion src/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -5708,7 +5708,10 @@ win_new_height(win_T *wp, int height)
wp->w_height = height;
wp->w_skipcol = 0;

scroll_to_fraction(wp, prev_height);
/* There is no point in adjusting the scroll position when exiting. Some
* values might be invalid. */
if (!exiting)
scroll_to_fraction(wp, prev_height);
}

void
Expand Down

0 comments on commit 955f198

Please sign in to comment.