unix: fix uv_spawn() NULL pointer deref on ENOMEM

In the cleanup-after-error section of uv_spawn(), check that the pointer
is non-NULL - we might end up in said section due to a malloc() failure.
This commit is contained in:
Ben Noordhuis 2013-10-02 10:53:53 +02:00
parent 8c9cbee1b1
commit fc3a21f943

View File

@ -463,11 +463,13 @@ int uv_spawn(uv_loop_t* loop,
error:
uv__set_sys_error(process->loop, errno);
for (i = 0; i < stdio_count; i++) {
close(pipes[i][0]);
close(pipes[i][1]);
if (pipes != NULL) {
for (i = 0; i < stdio_count; i++) {
close(pipes[i][0]);
close(pipes[i][1]);
}
free(pipes);
}
free(pipes);
return -1;
}