aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2016-06-09 14:49:55 +0200
committerMs2ger <Ms2ger@gmail.com>2016-06-09 14:51:10 +0200
commit7455dc4a500d96d7d4421682cd2e2929d2cd87a9 (patch)
tree4b81df13b62f4618ecbdb0c681bc9917de22e190
parent77e0089c1234b4a762f0676a46f1921c76b7f362 (diff)
downloadservo-7455dc4a500d96d7d4421682cd2e2929d2cd87a9.tar.gz
servo-7455dc4a500d96d7d4421682cd2e2929d2cd87a9.zip
Avoid an index-out-of-bounds error in ScriptMemoryFailsafe.
Fixes #11059. Fixes #11400. Fixes #11481. Fixes #11671. Fixes #11682.
-rw-r--r--components/script/dom/browsingcontext.rs6
-rw-r--r--components/script/script_thread.rs6
2 files changed, 10 insertions, 2 deletions
diff --git a/components/script/dom/browsingcontext.rs b/components/script/dom/browsingcontext.rs
index 99c72e1e4be..1b78fb7572d 100644
--- a/components/script/dom/browsingcontext.rs
+++ b/components/script/dom/browsingcontext.rs
@@ -108,6 +108,12 @@ impl BrowsingContext {
Root::from_ref(&self.history.borrow()[self.active_index.get()].document)
}
+ pub fn maybe_active_document(&self) -> Option<Root<Document>> {
+ self.history.borrow().get(self.active_index.get()).map(|entry| {
+ Root::from_ref(&*entry.document)
+ })
+ }
+
pub fn active_window(&self) -> Root<Window> {
Root::from_ref(self.active_document().window())
}
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 63fed6cf115..eec1853239e 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -422,8 +422,10 @@ impl<'a> Drop for ScriptMemoryFailsafe<'a> {
Some(owner) => {
let context = owner.browsing_context.get();
for context in context.iter() {
- let window = context.active_window();
- window.clear_js_runtime_for_script_deallocation();
+ if let Some(document) = context.maybe_active_document() {
+ let window = document.window();
+ window.clear_js_runtime_for_script_deallocation();
+ }
}
}
None => (),