0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

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.
This commit is contained in:
Bram Moolenaar
2017-02-05 15:10:51 +01:00
parent e971df39a5
commit 955f198fc5
6 changed files with 16 additions and 2 deletions

View File

@@ -1296,6 +1296,10 @@ getvcol(
posptr = NULL; /* continue until the NUL */ posptr = NULL; /* continue until the NUL */
else 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; posptr = ptr + pos->col;
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)

View File

@@ -889,6 +889,8 @@ mch_early_init(void)
void void
mch_exit(int r) mch_exit(int r)
{ {
exiting = TRUE;
if (raw_in) /* put terminal in 'normal' mode */ if (raw_in) /* put terminal in 'normal' mode */
{ {
settmode(TMODE_COOK); settmode(TMODE_COOK);

View File

@@ -201,6 +201,8 @@ int _stricoll(char *a, char *b)
void void
mch_exit(int r) mch_exit(int r)
{ {
exiting = TRUE;
display_errors(); display_errors();
ml_close_all(TRUE); /* remove all memfiles */ ml_close_all(TRUE); /* remove all memfiles */

View File

@@ -2538,8 +2538,9 @@ mch_init(void)
void void
mch_exit(int r) mch_exit(int r)
{ {
stoptermcap(); exiting = TRUE;
stoptermcap();
if (g_fWindInitCalled) if (g_fWindInitCalled)
settmode(TMODE_COOK); settmode(TMODE_COOK);

View File

@@ -764,6 +764,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 */
/**/
307,
/**/ /**/
306, 306,
/**/ /**/

View File

@@ -5708,7 +5708,10 @@ win_new_height(win_T *wp, int height)
wp->w_height = height; wp->w_height = height;
wp->w_skipcol = 0; 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 void