comparison src/terminal.c @ 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 5a5709918a98
children f7c2473796b7
comparison
equal deleted inserted replaced
11750:6116b2f75eb2 11751:a1815c4f8b70
1082 1082
1083 failed: 1083 failed:
1084 if (channel != NULL) 1084 if (channel != NULL)
1085 channel_clear(channel); 1085 channel_clear(channel);
1086 if (job != NULL) 1086 if (job != NULL)
1087 {
1088 job->jv_channel = NULL;
1087 job_cleanup(job); 1089 job_cleanup(job);
1090 }
1091 term->tl_job = NULL;
1088 if (jo != NULL) 1092 if (jo != NULL)
1089 CloseHandle(jo); 1093 CloseHandle(jo);
1090 if (term->tl_winpty != NULL) 1094 if (term->tl_winpty != NULL)
1091 winpty_free(term->tl_winpty); 1095 winpty_free(term->tl_winpty);
1096 term->tl_winpty = NULL;
1092 if (term->tl_winpty_config != NULL) 1097 if (term->tl_winpty_config != NULL)
1093 winpty_config_free(term->tl_winpty_config); 1098 winpty_config_free(term->tl_winpty_config);
1099 term->tl_winpty_config = NULL;
1094 if (winpty_err != NULL) 1100 if (winpty_err != NULL)
1095 { 1101 {
1096 char_u *msg = utf16_to_enc( 1102 char_u *msg = utf16_to_enc(
1097 (short_u *)winpty_error_msg(winpty_err), NULL); 1103 (short_u *)winpty_error_msg(winpty_err), NULL);
1098 1104
1106 * Free the terminal emulator part of "term". 1112 * Free the terminal emulator part of "term".
1107 */ 1113 */
1108 static void 1114 static void
1109 term_free(term_T *term) 1115 term_free(term_T *term)
1110 { 1116 {
1111 winpty_free(term->tl_winpty); 1117 if (term->tl_winpty != NULL)
1112 winpty_config_free(term->tl_winpty_config); 1118 winpty_free(term->tl_winpty);
1113 vterm_free(term->tl_vterm); 1119 if (term->tl_winpty_config != NULL)
1120 winpty_config_free(term->tl_winpty_config);
1121 if (term->tl_vterm != NULL)
1122 vterm_free(term->tl_vterm);
1114 } 1123 }
1115 1124
1116 # else 1125 # else
1117 1126
1118 /************************************** 1127 /**************************************
1147 * Free the terminal emulator part of "term". 1156 * Free the terminal emulator part of "term".
1148 */ 1157 */
1149 static void 1158 static void
1150 term_free(term_T *term) 1159 term_free(term_T *term)
1151 { 1160 {
1152 vterm_free(term->tl_vterm); 1161 if (term->tl_vterm != NULL)
1162 vterm_free(term->tl_vterm);
1153 } 1163 }
1154 # endif 1164 # endif
1155 1165
1156 #endif /* FEAT_TERMINAL */ 1166 #endif /* FEAT_TERMINAL */