From fc3a21f943d5c91cd27fd7df9a973546101fef22 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 2 Oct 2013 10:53:53 +0200 Subject: [PATCH] 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. --- src/unix/process.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unix/process.c b/src/unix/process.c index 7ef84d0d..ad7ca648 100644 --- a/src/unix/process.c +++ b/src/unix/process.c @@ -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; }