diff options
author | Anthony Ramine <nox@nox.paris> | 2020-03-29 19:57:47 +0200 |
---|---|---|
committer | Anthony Ramine <nox@nox.paris> | 2020-03-30 13:07:36 +0200 |
commit | ea9e62bdca95fb83e61e759fa5a93354e3ce3ee4 (patch) | |
tree | a4f9c00fb67864769011fa2c17b3c922ba7e3494 /components/script/dom/bindings | |
parent | 4279fe5933da5f3e70bbddc152c444dbbc517d13 (diff) | |
download | servo-ea9e62bdca95fb83e61e759fa5a93354e3ce3ee4.tar.gz servo-ea9e62bdca95fb83e61e759fa5a93354e3ce3ee4.zip |
Fix LayoutDom::unsafe_get
The raw pointer can be used to extend the lifetime of the inner T
to beyond 'dom.
Diffstat (limited to 'components/script/dom/bindings')
-rw-r--r-- | components/script/dom/bindings/root.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index b1739ac27c3..8fed6a584b3 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -748,12 +748,11 @@ impl<'dom, T> LayoutDom<'dom, T> where T: 'dom + DomObject, { - /// Returns an unsafe pointer to the interior of this JS object. This is - /// the only method that be safely accessed from layout. (The fact that - /// this is unsafe is what necessitates the layout wrappers.) - pub unsafe fn unsafe_get(&self) -> *const T { + /// Returns a reference to the interior of this JS object. The fact + /// that this is unsafe is what necessitates the layout wrappers. + pub unsafe fn unsafe_get(self) -> &'dom T { debug_assert!(thread_state::get().is_layout()); - self.ptr.as_ptr() + &*self.ptr.as_ptr() } } |