From 6f62d62c905c2335232ec8e5697036426bd171d4 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 15 Feb 2014 22:12:09 -0800 Subject: [PATCH] windows: always initialize uv_process_t The unix implementation of uv_spawn always starts out with a uv__handle_init, but the windows implementation sometimes bails out early before calling uv__handle_init. This means that uv_close on a failed uv_spawn will always succeed on unix but sometimes fail on windows. This commit lifts the initialization of the uv_process_t above all of the error checking to ensure that uv_close will always work when uv_spawn returns an error. --- src/win/process.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/win/process.c b/src/win/process.c index 813e522f75..88a141950d 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -811,6 +811,9 @@ int uv_spawn(uv_loop_t* loop, PROCESS_INFORMATION info; DWORD process_flags; + uv_process_init(loop, process); + process->exit_cb = options->exit_cb; + if (options->flags & (UV_PROCESS_SETGID | UV_PROCESS_SETUID)) { return UV_ENOTSUP; } @@ -827,9 +830,6 @@ int uv_spawn(uv_loop_t* loop, UV_PROCESS_WINDOWS_HIDE | UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS))); - uv_process_init(loop, process); - process->exit_cb = options->exit_cb; - err = uv_utf8_to_utf16_alloc(options->file, &application); if (err) goto done;