diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-07-27 21:46:43 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-07-27 21:46:43 +0200 |
commit | ab6eec3887d68c260b50b1b8f9ed95d49d9306c6 (patch) | |
tree | 20ec7e945235d6dca5527981c0e86abd5bef2951 | |
parent | cb25d1822094f2bc243cc2f64daf2e3b55f1d31b (diff) | |
download | vim-git-ab6eec3887d68c260b50b1b8f9ed95d49d9306c6.tar.gz |
patch 8.0.0781: MS-Windows: memory leak when using :terminalv8.0.0781
Problem: MS-Windows: Memory leak when using :terminal.
Solution: Handle failures properly. (Ken Takata)
-rw-r--r-- | src/terminal.c | 15 | ||||
-rw-r--r-- | src/version.c | 2 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/terminal.c b/src/terminal.c index 0532d01f9..6f14b3f82 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1153,18 +1153,19 @@ dyn_winpty_init(void) static int term_and_job_init(term_T *term, int rows, int cols, char_u *cmd) { - WCHAR *p = enc_to_utf16(cmd, NULL); + WCHAR *p; channel_T *channel = NULL; job_T *job = NULL; jobopt_T opt; DWORD error; HANDLE jo = NULL, child_process_handle, child_thread_handle; void *winpty_err; - void *spawn_config; + void *spawn_config = NULL; if (!dyn_winpty_init()) return FAIL; + p = enc_to_utf16(cmd, NULL); if (p == NULL) return FAIL; @@ -1227,9 +1228,14 @@ term_and_job_init(term_T *term, int rows, int cols, char_u *cmd) goto failed; if (!AssignProcessToJobObject(jo, child_process_handle)) - goto failed; + { + /* Failed, switch the way to terminate process with TerminateProcess. */ + CloseHandle(jo); + jo = NULL; + } winpty_spawn_config_free(spawn_config); + vim_free(p); create_vterm(term, rows, cols); @@ -1246,6 +1252,9 @@ term_and_job_init(term_T *term, int rows, int cols, char_u *cmd) return OK; failed: + if (spawn_config != NULL) + winpty_spawn_config_free(spawn_config); + vim_free(p); if (channel != NULL) channel_clear(channel); if (job != NULL) diff --git a/src/version.c b/src/version.c index ddac62f5a..f62d3f05b 100644 --- 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 */ /**/ + 781, +/**/ 780, /**/ 779, |