Skip to content

Truly independent web browser

LibWeb: Check for an empty handle in RetainedStyleValueData::data()

Andreas Klinge5f251b18ddd
diff --git a/Libraries/LibWeb/Rust/src/css/style_value.rs b/Libraries/LibWeb/Rust/src/css/style_value.rs
index e4ff7a274f1..0dfcd6b52e4 100644
--- a/Libraries/LibWeb/Rust/src/css/style_value.rs
+++ b/Libraries/LibWeb/Rust/src/css/style_value.rs
@@ -428,8 +428,9 @@ impl RetainedStyleValueData {
self.pointer.cast()
}
+ /// The handle's value, which an empty handle does not have.
pub(crate) fn data(&self) -> &StyleValueData {
- unsafe { &*self.pointer.cast::<StyleValueData>() }
+ self.optional_data().expect("an empty style value handle has no data")
}
pub(crate) fn optional_data(&self) -> Option<&StyleValueData> {