Skip to content

Commit cdeae99

Browse files
committed
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 #1864)
1 parent 9c5589c commit cdeae99

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/terminal.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,13 +1084,19 @@ term_and_job_init(term_T *term, int rows, int cols, char_u *cmd)
10841084
if (channel != NULL)
10851085
channel_clear(channel);
10861086
if (job != NULL)
1087+
{
1088+
job->jv_channel = NULL;
10871089
job_cleanup(job);
1090+
}
1091+
term->tl_job = NULL;
10881092
if (jo != NULL)
10891093
CloseHandle(jo);
10901094
if (term->tl_winpty != NULL)
10911095
winpty_free(term->tl_winpty);
1096+
term->tl_winpty = NULL;
10921097
if (term->tl_winpty_config != NULL)
10931098
winpty_config_free(term->tl_winpty_config);
1099+
term->tl_winpty_config = NULL;
10941100
if (winpty_err != NULL)
10951101
{
10961102
char_u *msg = utf16_to_enc(
@@ -1108,9 +1114,12 @@ term_and_job_init(term_T *term, int rows, int cols, char_u *cmd)
11081114
static void
11091115
term_free(term_T *term)
11101116
{
1111-
winpty_free(term->tl_winpty);
1112-
winpty_config_free(term->tl_winpty_config);
1113-
vterm_free(term->tl_vterm);
1117+
if (term->tl_winpty != NULL)
1118+
winpty_free(term->tl_winpty);
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);
11141123
}
11151124

11161125
# else
@@ -1149,7 +1158,8 @@ term_and_job_init(term_T *term, int rows, int cols, char_u *cmd)
11491158
static void
11501159
term_free(term_T *term)
11511160
{
1152-
vterm_free(term->tl_vterm);
1161+
if (term->tl_vterm != NULL)
1162+
vterm_free(term->tl_vterm);
11531163
}
11541164
# endif
11551165

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
758,
772774
/**/
773775
757,
774776
/**/

0 commit comments

Comments
 (0)