Bug 1415940 Part 4: Generalize a StyleSheet cast in ServoStyleRuleDeclaration::SetCSSDeclaration to prevent a NULL dereference from AsServo(). draft
authorBrad Werth <bwerth@mozilla.com>
Fri, 12 Jan 2018 14:54:48 -0800
changeset 721876 907b05d9ff666be7956aa7546a2b3f053a076155
parent 721875 5aeb29ffe4fcace90642e2b5a3a84ed09d8ac7a0
child 721877 c81f439f1adb43621ea77e3fc90fbda5573fb7d5
push id95979
push userbwerth@mozilla.com
push dateThu, 18 Jan 2018 00:40:34 +0000
bugs1415940
milestone59.0a1
Bug 1415940 Part 4: Generalize a StyleSheet cast in ServoStyleRuleDeclaration::SetCSSDeclaration to prevent a NULL dereference from AsServo(). MozReview-Commit-ID: GXHb3gLOEkt
layout/style/ServoStyleRule.cpp
--- a/layout/style/ServoStyleRule.cpp
+++ b/layout/style/ServoStyleRule.cpp
@@ -72,17 +72,17 @@ ServoStyleRuleDeclaration::GetCSSDeclara
 {
   return mDecls;
 }
 
 nsresult
 ServoStyleRuleDeclaration::SetCSSDeclaration(DeclarationBlock* aDecl)
 {
   ServoStyleRule* rule = Rule();
-  if (RefPtr<ServoStyleSheet> sheet = rule->GetStyleSheet()->AsServo()) {
+  if (RefPtr<StyleSheet> sheet = rule->GetStyleSheet()) {
     nsCOMPtr<nsIDocument> doc = sheet->GetAssociatedDocument();
     mozAutoDocUpdate updateBatch(doc, UPDATE_STYLE, true);
     if (aDecl != mDecls) {
       mDecls->SetOwningRule(nullptr);
       RefPtr<ServoDeclarationBlock> decls = aDecl->AsServo();
       Servo_StyleRule_SetStyle(rule->Raw(), decls->Raw());
       mDecls = decls.forget();
       mDecls->SetOwningRule(rule);