From d0481d1e8590e76db45b35af444c0f1ea35f0f47 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 22 Aug 2020 10:40:05 +0200 Subject: [PATCH] src: fix abort on uv_loop_init() failure Fixes: https://github.com/nodejs/node/issues/34855 PR-URL: https://github.com/nodejs/node/pull/34874 Reviewed-By: Gireesh Punathil Reviewed-By: Denys Otrishko Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- src/spawn_sync.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/spawn_sync.cc b/src/spawn_sync.cc index 11126c478f76f7..db5a66bc54cc54 100644 --- a/src/spawn_sync.cc +++ b/src/spawn_sync.cc @@ -457,9 +457,17 @@ Maybe SyncProcessRunner::TryInitializeAndRunLoop(Local options) { SetError(UV_ENOMEM); return Just(false); } - CHECK_EQ(uv_loop_init(uv_loop_), 0); + + r = uv_loop_init(uv_loop_); + if (r < 0) { + delete uv_loop_; + uv_loop_ = nullptr; + SetError(r); + return Just(false); + } if (!ParseOptions(options).To(&r)) return Nothing(); + if (r < 0) { SetError(r); return Just(false);