From 5f107d1794d84c96ab7c253c6e2292636d5bc48f Mon Sep 17 00:00:00 2001
From: Anna Henningsen <anna@addaleax.net>
Date: Mon, 28 Jan 2019 23:15:37 +0100
Subject: [PATCH] src: add handle scope to `OnFatalError()`
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

For the report generation, we use `Environment::GetCurrent(isolate)`
which uses `isolate->GetCurrentContext()` under the hood, thus
allocates a handle. Without a `HandleScope`, this is invalid.

This might not strictly be allowed inside of `OnFatalError()`,
but it won’t make anything worse either.
---
 src/node_errors.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/node_errors.cc b/src/node_errors.cc
index c7a449c8c50a4a..23a65bd2251d62 100644
--- a/src/node_errors.cc
+++ b/src/node_errors.cc
@@ -319,6 +319,7 @@ void OnFatalError(const char* location, const char* message) {
   }
 #ifdef NODE_REPORT
   Isolate* isolate = Isolate::GetCurrent();
+  HandleScope handle_scope(isolate);
   Environment* env = Environment::GetCurrent(isolate);
   if (env != nullptr) {
     std::shared_ptr<PerIsolateOptions> options = env->isolate_data()->options();