diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index 0689aa6c0c4..39f7d7cc8d8 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -56,10 +56,17 @@ impl GeckoStyleSheet { /// already holds a strong reference. #[inline] pub unsafe fn from_addrefed(s: *const DomStyleSheet) -> Self { - debug_assert!(!s.is_null()); + assert!(!s.is_null()); GeckoStyleSheet(s) } + /// HACK(emilio): This is so that we can avoid crashing release due to + /// bug 1719963 and can hopefully get a useful report from fuzzers. + #[inline] + pub fn hack_is_null(&self) -> bool { + self.0.is_null() + } + /// Get the raw `StyleSheet` that we're wrapping. pub fn raw(&self) -> &DomStyleSheet { unsafe { &*self.0 } diff --git a/components/style/stylesheets/import_rule.rs b/components/style/stylesheets/import_rule.rs index 396be242024..8f518f29bac 100644 --- a/components/style/stylesheets/import_rule.rs +++ b/components/style/stylesheets/import_rule.rs @@ -56,7 +56,13 @@ impl ImportSheet { /// exists. pub fn as_sheet(&self) -> Option<&crate::gecko::data::GeckoStyleSheet> { match *self { - ImportSheet::Sheet(ref s) => Some(s), + ImportSheet::Sheet(ref s) => { + debug_assert!(!s.hack_is_null()); + if s.hack_is_null() { + return None; + } + Some(s) + }, ImportSheet::Pending(_) => None, } }