Don't try to get the global of an object while it's being destroyed.

Fixes #15070.
Fixes #15097.
This commit is contained in:
Ms2ger 2017-01-19 10:08:27 +01:00
parent b8df502491
commit 2071e41e64
2 changed files with 3 additions and 2 deletions

2
Cargo.lock generated
View file

@ -1257,7 +1257,7 @@ dependencies = [
[[package]]
name = "js"
version = "0.1.3"
source = "git+https://github.com/servo/rust-mozjs#568eccb62c8b139450d74bb8ed34e464ada715b2"
source = "git+https://github.com/servo/rust-mozjs#71acb0c504abbbc9c396bd78c71af4ec4ea91c88"
dependencies = [
"cmake 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
"heapsize 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -15,6 +15,7 @@ use js::jsapi::{JSCompartment, JS_EnterCompartment, JS_LeaveCompartment, RemoveR
use js::jsapi::JSAutoCompartment;
use js::jsapi::JS_GetProperty;
use js::jsval::{JSVal, UndefinedValue, ObjectValue};
use js::rust::Runtime;
use std::default::Default;
use std::ffi::CString;
use std::mem::drop;
@ -88,7 +89,7 @@ impl Drop for CallbackObject {
#[allow(unsafe_code)]
fn drop(&mut self) {
unsafe {
let cx = GlobalScope::from_object(self.callback.get()).get_cx();
let cx = Runtime::get();
RemoveRawValueRoot(cx, self.permanent_js_root.get_unsafe());
}
}