From 8e5afeccc9c6469f33866736d7458f44f3943c3e Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Tue, 19 Apr 2016 03:58:23 -0700 Subject: [PATCH] Fix another crash involving protected values --- src/js_realm.hpp | 5 ++++- src/jsc/jsc_protected.hpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/js_realm.hpp b/src/js_realm.hpp index f6cdc13f..b3cb1351 100644 --- a/src/js_realm.hpp +++ b/src/js_realm.hpp @@ -63,7 +63,10 @@ class RealmDelegate : public BindingContext { RealmDelegate(std::weak_ptr realm, GlobalContextType ctx) : m_context(ctx), m_realm(realm) {} ~RealmDelegate() { - remove_all_notifications(); + // All protected values need to be unprotected while the context is retained. + m_defaults.clear(); + m_constructors.clear(); + m_notifications.clear(); } void add_notification(FunctionType notification) { diff --git a/src/jsc/jsc_protected.hpp b/src/jsc/jsc_protected.hpp index a330ba3a..39a8e198 100644 --- a/src/jsc/jsc_protected.hpp +++ b/src/jsc/jsc_protected.hpp @@ -32,7 +32,7 @@ class Protected { Protected(Protected &&other) : m_context(other.m_context) { other.m_context = nullptr; } - Protected(JSGlobalContextRef ctx) : m_context(ctx) { + explicit Protected(JSGlobalContextRef ctx) : m_context(ctx) { JSGlobalContextRetain(m_context); } ~Protected() {