]> granicus.if.org Git - vim/commitdiff
patch 8.0.0307: asan detects a memory error when EXITFREE is defined v8.0.0307
authorBram Moolenaar <Bram@vim.org>
Sun, 5 Feb 2017 14:10:51 +0000 (15:10 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 5 Feb 2017 14:10:51 +0000 (15:10 +0100)
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.

src/charset.c
src/os_amiga.c
src/os_mswin.c
src/os_win32.c
src/version.c
src/window.c

index eb8baa946543688e21bec05ce2a2801a9a2da81c..984d7653e7816a95e08915a3a6decbab4097a748 100644 (file)
@@ -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)
index 9266380d6dd9d1c6a8d4453fb03f045ad14be3c9..87fcca97e12fc7b234be1d565a64691ba6407758 100644 (file)
@@ -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);
index 14fe8c6a22ced789d3d85e769cdf8c7e5f03b407..5f6e11dab6bf76efb278e9512335fed76f9d0dac 100644 (file)
@@ -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 */
index d35061fbf10d5ebb020d222eea0b529d62115ac4..adbb199b9dfb45eafd0828e450e599b1066d8596 100644 (file)
@@ -2538,8 +2538,9 @@ mch_init(void)
     void
 mch_exit(int r)
 {
-    stoptermcap();
+    exiting = TRUE;
 
+    stoptermcap();
     if (g_fWindInitCalled)
        settmode(TMODE_COOK);
 
index e0fa3cb395784130fabc41409a5752d907a9ffda..5627b3db62c74c8912251d2eeeecaf0d1ab42bfd 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    307,
 /**/
     306,
 /**/
index ee5f7aa8aa6ec14f8bfa609a8d03783877da19ef..6b7bd353a41ab148ce69935ecde14b125084f3ed 100644 (file)
@@ -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