From 6ea2755095a6d5a73e94da5d4de11214201a1ce7 Mon Sep 17 00:00:00 2001 From: Matt Crocker Date: Mon, 23 Oct 2017 23:19:23 -0700 Subject: [PATCH] Upstream Muon changes to avoid crashing --- native_mate/function_template.h | 3 +++ native_mate/wrappable.cc | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/native_mate/function_template.h b/native_mate/function_template.h index 50c427a1dab2..abbe7b5326e1 100644 --- a/native_mate/function_template.h +++ b/native_mate/function_template.h @@ -21,6 +21,9 @@ namespace internal { struct Destroyable { static void Destroy(Arguments* args) { + if (IsDestroyed(args)) + return; + v8::Local holder = args->GetHolder(); delete static_cast( holder->GetAlignedPointerFromInternalField(0)); diff --git a/native_mate/wrappable.cc b/native_mate/wrappable.cc index 6743a139f54e..005c83b8dc0a 100644 --- a/native_mate/wrappable.cc +++ b/native_mate/wrappable.cc @@ -24,8 +24,11 @@ WrappableBase::~WrappableBase() { } v8::Local WrappableBase::GetWrapper() { - CHECK(!wrapper_.IsEmpty()); - return v8::Local::New(isolate_, wrapper_); + DCHECK(!wrapper_.IsEmpty()); + if (!wrapper_.IsEmpty()) + return v8::Local::New(isolate_, wrapper_); + else + return v8::Local(); } void WrappableBase::InitWith(v8::Isolate* isolate,