]> granicus.if.org Git - vim/commitdiff
patch 8.0.0758: possible crash when using a terminal window v8.0.0758
authorBram Moolenaar <Bram@vim.org>
Sun, 23 Jul 2017 15:22:35 +0000 (17:22 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 23 Jul 2017 15:22:35 +0000 (17:22 +0200)
Problem:    Possible crash when using a terminal window.
Solution:   Check for NULL pointers. (Yasuhiro Matsumoto, closes #1864)

src/terminal.c
src/version.c

index 5fbfc2eea41242e72a29c00cdf8fb50056ba0fc6..d1ed569ea399afe762297c58e48c7a35294009bd 100644 (file)
@@ -1084,13 +1084,19 @@ failed:
     if (channel != NULL)
        channel_clear(channel);
     if (job != NULL)
+    {
+       job->jv_channel = NULL;
        job_cleanup(job);
+    }
+    term->tl_job = NULL;
     if (jo != NULL)
        CloseHandle(jo);
     if (term->tl_winpty != NULL)
        winpty_free(term->tl_winpty);
+    term->tl_winpty = NULL;
     if (term->tl_winpty_config != NULL)
        winpty_config_free(term->tl_winpty_config);
+    term->tl_winpty_config = NULL;
     if (winpty_err != NULL)
     {
        char_u *msg = utf16_to_enc(
@@ -1108,9 +1114,12 @@ failed:
     static void
 term_free(term_T *term)
 {
-    winpty_free(term->tl_winpty);
-    winpty_config_free(term->tl_winpty_config);
-    vterm_free(term->tl_vterm);
+    if (term->tl_winpty != NULL)
+       winpty_free(term->tl_winpty);
+    if (term->tl_winpty_config != NULL)
+       winpty_config_free(term->tl_winpty_config);
+    if (term->tl_vterm != NULL)
+       vterm_free(term->tl_vterm);
 }
 
 # else
@@ -1149,7 +1158,8 @@ term_and_job_init(term_T *term, int rows, int cols, char_u *cmd)
     static void
 term_free(term_T *term)
 {
-    vterm_free(term->tl_vterm);
+    if (term->tl_vterm != NULL)
+       vterm_free(term->tl_vterm);
 }
 # endif
 
index ad2a45d19413129a457a623823e964882ef37d85..bfeedcd4d42fc7003f01d9cf26d34dedcff75f6b 100644 (file)
@@ -769,6 +769,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    758,
 /**/
     757,
 /**/