Bug 1343552 - Part 2: Record attempted misuse of gfxSkipCharsIterator via a gfxCriticalError. r=mats, a=lizzard
authorJonathan Kew <jkew@mozilla.com>
Mon, 06 Mar 2017 17:31:01 +0000
changeset 376722 ef9c28e77417c83d7688842b3a91ce37e20b5f87
parent 376721 ddbca773eb5376aa6351d471e69364bdb8b9b254
child 376723 e7c5970badab988fa220c818162273be8c3683ba
push id7027
push userryanvm@gmail.com
push dateFri, 10 Mar 2017 22:55:20 +0000
treeherdermozilla-beta@20b587aa00a8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats, lizzard
bugs1343552
milestone53.0
Bug 1343552 - Part 2: Record attempted misuse of gfxSkipCharsIterator via a gfxCriticalError. r=mats, a=lizzard MozReview-Commit-ID: CayLp1dGSnq
gfx/thebes/gfxSkipChars.cpp
--- a/gfx/thebes/gfxSkipChars.cpp
+++ b/gfx/thebes/gfxSkipChars.cpp
@@ -14,18 +14,22 @@ struct SkippedRangeStartComparator
         return (mOffset < aRange.Start()) ? -1 : 1;
     }
 };
 
 void
 gfxSkipCharsIterator::SetOriginalOffset(int32_t aOffset)
 {
     aOffset += mOriginalStringToSkipCharsOffset;
-    NS_ASSERTION(uint32_t(aOffset) <= mSkipChars->mCharCount,
-                 "Invalid offset");
+    if (MOZ_UNLIKELY(uint32_t(aOffset) > mSkipChars->mCharCount)) {
+        gfxCriticalError() <<
+            "invalid offset " << aOffset <<
+            " for gfxSkipChars length " << mSkipChars->mCharCount;
+        aOffset = mSkipChars->mCharCount;
+    }
 
     mOriginalStringOffset = aOffset;
 
     const uint32_t rangeCount = mSkipChars->mRanges.Length();
     if (rangeCount == 0) {
         mSkippedStringOffset = aOffset;
         return;
     }