From fff1e7f86c83fd4d9452021052cbb062d87a5254 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 d7d06be34bdb10..1141aceae984fb 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);