diff options
author | Josh Matthews <josh@joshmatthews.net> | 2017-05-26 12:29:31 -0400 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2017-09-25 16:10:58 -0400 |
commit | da65698c5c5934220b82493b3f7bb2ab05a2e512 (patch) | |
tree | ebb8646bbbde4b988d55758598b6ea724149b79f /components/script/dom/bindings/iterable.rs | |
parent | e481e8934a0c37a4b1eba19862ff732ec9bf19c9 (diff) | |
download | servo-da65698c5c5934220b82493b3f7bb2ab05a2e512.tar.gz servo-da65698c5c5934220b82493b3f7bb2ab05a2e512.zip |
Be more conservative about safety of dictionary and union values.
Mark dictionaries containing GC values as must_root, and wrap them in
RootedTraceableBox in automatically-generated APIs. To accommodate
union variants that are now flagged as unsafe, add RootedTraceableBox
to union variants that need to be rooted, rather than wrapping the
entire union value.
Diffstat (limited to 'components/script/dom/bindings/iterable.rs')
-rw-r--r-- | components/script/dom/bindings/iterable.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/components/script/dom/bindings/iterable.rs b/components/script/dom/bindings/iterable.rs index 03fac1cb27f..39c681c7d8b 100644 --- a/components/script/dom/bindings/iterable.rs +++ b/components/script/dom/bindings/iterable.rs @@ -12,7 +12,7 @@ use dom::bindings::codegen::Bindings::IterableIteratorBinding::IterableKeyOrValu use dom::bindings::error::Fallible; use dom::bindings::js::{JS, Root}; use dom::bindings::reflector::{DomObject, Reflector, reflect_dom_object}; -use dom::bindings::trace::JSTraceable; +use dom::bindings::trace::{JSTraceable, RootedTraceableBox}; use dom::globalscope::GlobalScope; use dom_struct::dom_struct; use js::conversions::ToJSValConvertible; @@ -115,7 +115,7 @@ fn dict_return(cx: *mut JSContext, result: MutableHandleObject, done: bool, value: HandleValue) -> Fallible<()> { - let mut dict = unsafe { IterableKeyOrValueResult::empty(cx) }; + let mut dict = RootedTraceableBox::new(unsafe { IterableKeyOrValueResult::empty(cx) }); dict.done = done; dict.value.set(value.get()); rooted!(in(cx) let mut dict_value = UndefinedValue()); @@ -130,7 +130,7 @@ fn key_and_value_return(cx: *mut JSContext, result: MutableHandleObject, key: HandleValue, value: HandleValue) -> Fallible<()> { - let mut dict = unsafe { IterableKeyAndValueResult::empty(cx) }; + let mut dict = RootedTraceableBox::new(unsafe { IterableKeyAndValueResult::empty(cx) }); dict.done = false; dict.value = Some(vec![Heap::new(key.get()), Heap::new(value.get())]); rooted!(in(cx) let mut dict_value = UndefinedValue()); |