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

Commit

Permalink
unix: fix uv_spawn() NULL pointer deref on ENOMEM
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bnoordhuis committed Oct 2, 2013
1 parent 8c9cbee commit fc3a21f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/unix/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit fc3a21f

Please sign in to comment.