Skip to content
This repository was archived by the owner on May 4, 2018. It is now read-only.

Commit 6f62d62

Browse files
alexcrichtonsaghul
authored andcommitted
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.
1 parent 8692bbc commit 6f62d62

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/win/process.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,9 @@ int uv_spawn(uv_loop_t* loop,
811811
PROCESS_INFORMATION info;
812812
DWORD process_flags;
813813

814+
uv_process_init(loop, process);
815+
process->exit_cb = options->exit_cb;
816+
814817
if (options->flags & (UV_PROCESS_SETGID | UV_PROCESS_SETUID)) {
815818
return UV_ENOTSUP;
816819
}
@@ -827,9 +830,6 @@ int uv_spawn(uv_loop_t* loop,
827830
UV_PROCESS_WINDOWS_HIDE |
828831
UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS)));
829832

830-
uv_process_init(loop, process);
831-
process->exit_cb = options->exit_cb;
832-
833833
err = uv_utf8_to_utf16_alloc(options->file, &application);
834834
if (err)
835835
goto done;

0 commit comments

Comments
 (0)