Hi,
I found memory leakage in term_and_job_init() on Win32.
I also added a workaround when AssignProcessToJobObject() failed. This the same
as mch_job_start() in os_win32.c and would be useful on Windows 7 or earlier.
Please check the attached patch.
Regards,
Ken Takata
--
--
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.
# HG changeset patch
# Parent a959af2e74d0a519c94381968293c6a06646205a
diff --git a/src/terminal.c b/src/terminal.c
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -1153,7 +1153,7 @@ 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;
@@ -1165,6 +1165,7 @@ term_and_job_init(term_T *term, int rows
if (!dyn_winpty_init())
return FAIL;
+ p = enc_to_utf16(cmd, NULL);
if (p == NULL)
return FAIL;
@@ -1227,7 +1228,12 @@ term_and_job_init(term_T *term, int rows
goto failed;
if (!AssignProcessToJobObject(jo, child_process_handle))
- goto failed;
+ {
+ /* if failing, switch the way to terminate
+ * process with TerminateProcess. */
+ CloseHandle(jo);
+ jo = NULL;
+ }
winpty_spawn_config_free(spawn_config);
@@ -1243,9 +1249,11 @@ term_and_job_init(term_T *term, int rows
job->jv_status = JOB_STARTED;
term->tl_job = job;
+ vim_free(p);
return OK;
failed:
+ vim_free(p);
if (channel != NULL)
channel_clear(channel);
if (job != NULL)