summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-02-05 15:10:51 +0100
committerBram Moolenaar <Bram@vim.org>2017-02-05 15:10:51 +0100
commit955f198fc546cc30a34361932d3f454a61df0efa (patch)
tree04a9cf18bd3af2e373747341d91e6bcc86332690 /src
parente971df39a5aac5d9b7e8033247dc18b12daa0eb8 (diff)
downloadvim-git-955f198fc546cc30a34361932d3f454a61df0efa.tar.gz
patch 8.0.0307: asan detects a memory error when EXITFREE is definedv8.0.0307
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.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c4
-rw-r--r--src/os_amiga.c2
-rw-r--r--src/os_mswin.c2
-rw-r--r--src/os_win32.c3
-rw-r--r--src/version.c2
-rw-r--r--src/window.c5
6 files changed, 16 insertions, 2 deletions
diff --git a/src/charset.c b/src/charset.c
index eb8baa946..984d7653e 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -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)
diff --git a/src/os_amiga.c b/src/os_amiga.c
index 9266380d6..87fcca97e 100644
--- a/src/os_amiga.c
+++ b/src/os_amiga.c
@@ -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);
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 14fe8c6a2..5f6e11dab 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -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 */
diff --git a/src/os_win32.c b/src/os_win32.c
index d35061fbf..adbb199b9 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -2538,8 +2538,9 @@ mch_init(void)
void
mch_exit(int r)
{
- stoptermcap();
+ exiting = TRUE;
+ stoptermcap();
if (g_fWindInitCalled)
settmode(TMODE_COOK);
diff --git a/src/version.c b/src/version.c
index e0fa3cb39..5627b3db6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -765,6 +765,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 307,
+/**/
306,
/**/
305,
diff --git a/src/window.c b/src/window.c
index ee5f7aa8a..6b7bd353a 100644
--- a/src/window.c
+++ b/src/window.c
@@ -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