Bug 1512758. r=smaug, a=RyanVM
authorHenri Sivonen <hsivonen@hsivonen.fi>
Thu, 20 Dec 2018 09:15:58 +0000
changeset 509267 c511b04377a198c6da03b32ea27e7d042e75fda1
parent 509266 ef2cd013fe73a216735629f5fab931c6ccbdd29d
child 509268 b168e29f3c821f8d170d99c42bec442eb32351de
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, RyanVM
bugs1512758
milestone65.0
Bug 1512758. r=smaug, a=RyanVM Differential Revision: https://phabricator.services.mozilla.com/D14141
dom/base/nsContentUtils.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -8547,18 +8547,21 @@ class StringBuilder {
     Unit* u = AddUnit();
     u->mTextFragment = aTextFragment;
     u->mType = Unit::eTextFragmentWithEncode;
     u->mLength = aLen;
     mLength += aLen;
   }
 
   bool ToString(nsAString& aOut) {
+    if (!mLength.isValid()) {
+      return false;
+    }
     nsresult rv;
-    BulkAppender appender(aOut.BulkWrite(mLength, 0, true, rv));
+    BulkAppender appender(aOut.BulkWrite(mLength.value(), 0, true, rv));
     if (NS_FAILED(rv)) {
       return false;
     }
 
     for (StringBuilder* current = this; current; current = current->mNext) {
       uint32_t len = current->mUnits.Length();
       for (uint32_t i = 0; i < len; ++i) {
         Unit& u = current->mUnits[i];
@@ -8683,17 +8686,17 @@ class StringBuilder {
       aAppender.Append(aStr.FromTo(flushedUntil, currentPosition));
     }
   }
 
   AutoTArray<Unit, STRING_BUFFER_UNITS> mUnits;
   nsAutoPtr<StringBuilder> mNext;
   StringBuilder* mLast;
   // mLength is used only in the first StringBuilder object in the linked list.
-  uint32_t mLength;
+  CheckedInt<uint32_t> mLength;
 };
 
 }  // namespace
 
 static void AppendEncodedCharacters(const nsTextFragment* aText,
                                     StringBuilder& aBuilder) {
   uint32_t extraSpaceNeeded = 0;
   uint32_t len = aText->GetLength();