Bug 1364133 - Part 1. Check whether SplitNode returns error. r?masayuki
When SplitNode returns nullptr, GetAsText causes crash. So we should check
error before casting by GetAsText.
MozReview-Commit-ID: 8E1OPSRZ2x5
--- a/editor/libeditor/HTMLStyleEditor.cpp
+++ b/editor/libeditor/HTMLStyleEditor.cpp
@@ -282,20 +282,20 @@ HTMLEditor::SetInlinePropertyOnTextNode(
}
} else if (IsTextPropertySetByContent(&aText, &aProperty, aAttribute,
&aValue)) {
return NS_OK;
}
// Do we need to split the text node?
ErrorResult rv;
- RefPtr<Text> text = &aText;
+ nsCOMPtr<nsIContent> text = &aText;
if (uint32_t(aEndOffset) != aText.Length()) {
// We need to split off back of text node
- text = SplitNode(aText, aEndOffset, rv)->GetAsText();
+ text = SplitNode(*text, aEndOffset, rv);
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
}
if (aStartOffset) {
// We need to split off front of text node
SplitNode(*text, aStartOffset, rv);
NS_ENSURE_TRUE(!rv.Failed(), rv.StealNSResult());
}