changeset 11751:a1815c4f8b70 v8.0.0758

patch 8.0.0758: possible crash when using a terminal window commit https://github.com/vim/vim/commit/cdeae99b4ef4d359e4388a72c6d35f9343ce578a Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 23 17:22:35 2017 +0200 patch 8.0.0758: possible crash when using a terminal window Problem: Possible crash when using a terminal window. Solution: Check for NULL pointers. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/1864)
author Christian Brabandt <cb@256bit.org>
date Sun, 23 Jul 2017 17:30:05 +0200
parents 6116b2f75eb2
children c69cf4215217
files src/terminal.c src/version.c
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -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
     static void
 term_free(term_T *term)
 {
-    vterm_free(term->tl_vterm);
+    if (term->tl_vterm != NULL)
+	vterm_free(term->tl_vterm);
 }
 # endif
 
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    758,
+/**/
     757,
 /**/
     756,