Patch 8.0.0781
Problem: MS-Windows: Memory leak when using :terminal.
Solution: Handle failures properly. (Ken Takata)
Files: src/terminal.c
*** ../vim-8.0.0780/src/terminal.c 2017-07-26 23:10:57.750113304 +0200
--- src/terminal.c 2017-07-27 21:43:46.175173768 +0200
***************
*** 1153,1170 ****
static int
term_and_job_init(term_T *term, int rows, int cols, char_u *cmd)
{
! WCHAR *p = enc_to_utf16(cmd, NULL);
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;
if (!dyn_winpty_init())
return FAIL;
if (p == NULL)
return FAIL;
--- 1153,1171 ----
static int
term_and_job_init(term_T *term, int rows, int cols, char_u *cmd)
{
! 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 = NULL;
if (!dyn_winpty_init())
return FAIL;
+ p = enc_to_utf16(cmd, NULL);
if (p == NULL)
return FAIL;
***************
*** 1227,1235 ****
goto failed;
if (!AssignProcessToJobObject(jo, child_process_handle))
! goto failed;
winpty_spawn_config_free(spawn_config);
create_vterm(term, rows, cols);
--- 1228,1241 ----
goto failed;
if (!AssignProcessToJobObject(jo, child_process_handle))
! {
! /* 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,1251 ****
--- 1252,1260 ----
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)
*** ../vim-8.0.0780/src/version.c 2017-07-27 21:29:27.917184701 +0200
--- src/version.c 2017-07-27 21:40:18.012630365 +0200
***************
*** 771,772 ****
--- 771,774 ----
{ /* Add new patch number below this line */
+ /**/
+ 781,
/**/
--
GALAHAD: Camelot ...
LAUNCELOT: Camelot ...
GAWAIN: It's only a model.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.