From 1e7307601d24697bd748f6a5f9f398715f06d8c9 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 3 Aug 2016 12:52:14 -0700 Subject: [PATCH] Properly deallocate PrivateStyleData. In Servo_DropNodeData, we do Box::::from_raw, which is off by one level of indirection with the current types. --- ports/geckolib/wrapper.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ports/geckolib/wrapper.rs b/ports/geckolib/wrapper.rs index d71666975a0..6fc4a319c2a 100644 --- a/ports/geckolib/wrapper.rs +++ b/ports/geckolib/wrapper.rs @@ -49,7 +49,8 @@ use style::selector_impl::ElementExt; use style::sink::Push; use url::Url; -pub type NonOpaqueStyleData = *mut RefCell; +pub type NonOpaqueStyleData = RefCell; +pub type NonOpaqueStyleDataPtr = *mut NonOpaqueStyleData; // Important: We don't currently refcount the DOM, because the wrapper lifetime // magic guarantees that our LayoutFoo references won't outlive the root, and @@ -74,16 +75,16 @@ impl<'ln> GeckoNode<'ln> { GeckoNode::from_raw(n as *const RawGeckoNode as *mut RawGeckoNode) } - fn get_node_data(&self) -> NonOpaqueStyleData { + fn get_node_data(&self) -> NonOpaqueStyleDataPtr { unsafe { - Gecko_GetNodeData(self.node) as NonOpaqueStyleData + Gecko_GetNodeData(self.node) as NonOpaqueStyleDataPtr } } pub fn initialize_data(self) { unsafe { if self.get_node_data().is_null() { - let ptr: NonOpaqueStyleData = Box::into_raw(Box::new(RefCell::new(PrivateStyleData::new()))); + let ptr: NonOpaqueStyleDataPtr = Box::into_raw(Box::new(RefCell::new(PrivateStyleData::new()))); Gecko_SetNodeData(self.node, ptr as *mut ServoNodeData); } }