From 288382a4ce4c1eb5d6eaccf698099804f6a3697d Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 11 Nov 2019 12:29:07 +0000 Subject: [PATCH] src: fix memory leak in CreateEnvironment when bootstrap fails PR-URL: https://github.com/nodejs/node/pull/30467 Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil --- src/api/environment.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/api/environment.cc b/src/api/environment.cc index 02e9991e1522a5..23bae50d6da7ab 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -349,8 +349,10 @@ Environment* CreateEnvironment(IsolateData* isolate_data, Environment::kOwnsProcessState | Environment::kOwnsInspector)); env->InitializeLibuv(per_process::v8_is_profiling); - if (env->RunBootstrapping().IsEmpty()) + if (env->RunBootstrapping().IsEmpty()) { + FreeEnvironment(env); return nullptr; + } return env; }