Bug 1503744 - Make HTMLEditor::SetHTMLBackgroundColorWithTransaction() not refer RefPtr after moving it. r=m_kato a=jcristau
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 05 Nov 2018 02:13:05 +0000
changeset 501040 2b2c323a635295870bfc3d4e5bf511185857a36e
parent 501039 9aacd377517c9d54df39a717b6f474e3666389ef
child 501041 fa8dfa3aef26a452b800502fa4e6ebf956e64c5e
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato, jcristau
bugs1503744
milestone64.0
Bug 1503744 - Make HTMLEditor::SetHTMLBackgroundColorWithTransaction() not refer RefPtr after moving it. r=m_kato a=jcristau Simple fix of crash caused by referring nullptr. Differential Revision: https://phabricator.services.mozilla.com/D10705
editor/libeditor/HTMLEditor.cpp
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3013,18 +3013,18 @@ HTMLEditor::SetHTMLBackgroundColorWithTr
   if (cellOrRowOrTableElement) {
     rootElementOfBackgroundColor = std::move(cellOrRowOrTableElement);
     // Needs to set or remove background color of each selected cell elements.
     // Therefore, just the cell contains selection range, we don't need to
     // do this.  Note that users can select each cell, but with Selection API,
     // web apps can select <tr> and <td> at same time. With <table>, looks
     // odd, though.
     if (isCellSelected ||
-        cellOrRowOrTableElement->IsAnyOfHTMLElements(nsGkAtoms::table,
-                                                    nsGkAtoms::tr)) {
+        rootElementOfBackgroundColor->IsAnyOfHTMLElements(nsGkAtoms::table,
+                                                          nsGkAtoms::tr)) {
       IgnoredErrorResult ignoredError;
       RefPtr<Element> cellElement =
         GetFirstSelectedTableCellElement(*selection, ignoredError);
       if (cellElement) {
         if (setColor) {
           while (cellElement) {
             nsresult rv =
               SetAttributeWithTransaction(*cellElement, *nsGkAtoms::bgcolor,