Bug 1575584: prevent reading uninitialized variable in `TextEditor::ComputeValueInternal`. r=masayuki
authorMirko Brodesser <mbrodesser@mozilla.com>
Fri, 23 Aug 2019 09:25:00 +0000
changeset 553313 c8fcbaade215ecf3cd353b4196787d8c5826527a
parent 553312 a7b4cf929f403e089a769b88865fd25dc2ec5a9d
child 553314 faf2a38a5c062b9c986e1bad3d422e6db9cf498e
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1575584
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1575584: prevent reading uninitialized variable in `TextEditor::ComputeValueInternal`. r=masayuki The fix here is to first check `NS_FAILED(rv)`, because if that's the case, `cancel` wasn't necessarily set to a value. As best practice I initialized `cancel` and `handled` with default values. Differential Revision: https://phabricator.services.mozilla.com/D43071
editor/libeditor/TextEditor.cpp
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -1879,19 +1879,20 @@ nsresult TextEditor::ComputeValueInterna
   // Protect the edit rules object from dying
   RefPtr<TextEditRules> rules(mRules);
 
   EditSubActionInfo subActionInfo(EditSubAction::eComputeTextToOutput);
   subActionInfo.outString = &aOutputString;
   subActionInfo.flags = aDocumentEncoderFlags;
   subActionInfo.outputFormat = &aFormatType;
 
-  bool cancel, handled;
+  bool cancel{false};
+  bool handled{false};
   nsresult rv = rules->WillDoAction(subActionInfo, &cancel, &handled);
-  if (cancel || NS_FAILED(rv)) {
+  if (NS_FAILED(rv) || cancel) {
     return rv;
   }
   if (handled) {
     // This case will get triggered by password fields or single text node only.
     return rv;
   }
 
   nsAutoCString charset;