Bug 724453. Don't assume that sizeof(bool) == 1 when memsetting arrays of bools in nsTextFrame. r=bzbarsky
authorCameron Kaiser <spectre@armory.com>
Mon, 06 Feb 2012 13:00:54 -0500
changeset 86248 b27b65ade4a69842952c3b15cc1b5160a1d08557
parent 86247 50c00def777afb3c99f929ba11195bb3c554c15e
child 86249 86dee2f0897bf86c6c162615d30cd5cfc193d4df
push id22008
push userbmo@edmorley.co.uk
push dateTue, 07 Feb 2012 10:32:58 +0000
treeherdermozilla-central@2b61af9d18ee [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs724453
milestone13.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 724453. Don't assume that sizeof(bool) == 1 when memsetting arrays of bools in nsTextFrame. r=bzbarsky
layout/generic/nsTextFrameThebes.cpp
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -3022,17 +3022,17 @@ PropertyProvider::GetHyphenationBreaks(P
                                        bool* aBreakBefore)
 {
   NS_PRECONDITION(IsInBounds(mStart, mLength, aStart, aLength), "Range out of bounds");
   NS_PRECONDITION(mLength != PR_INT32_MAX, "Can't call this with undefined length");
 
   if (!mTextStyle->WhiteSpaceCanWrap() ||
       mTextStyle->mHyphens == NS_STYLE_HYPHENS_NONE)
   {
-    memset(aBreakBefore, false, aLength);
+    memset(aBreakBefore, false, aLength*sizeof(bool));
     return;
   }
 
   // Iterate through the original-string character runs
   nsSkipCharsRunIterator
     run(mStart, nsSkipCharsRunIterator::LENGTH_UNSKIPPED_ONLY, aLength);
   run.SetSkippedOffset(aStart);
   // We need to visit skipped characters so that we can detect SHY
@@ -3049,17 +3049,17 @@ PropertyProvider::GetHyphenationBreaks(P
     if (run.IsSkipped()) {
       // Check if there's a soft hyphen which would let us hyphenate before
       // the next non-skipped character. Don't look at soft hyphens followed
       // by other skipped characters, we won't use them.
       allowHyphenBreakBeforeNextChar =
         mFrag->CharAt(run.GetOriginalOffset() + run.GetRunLength() - 1) == CH_SHY;
     } else {
       PRInt32 runOffsetInSubstring = run.GetSkippedOffset() - aStart;
-      memset(aBreakBefore + runOffsetInSubstring, false, run.GetRunLength());
+      memset(aBreakBefore + runOffsetInSubstring, false, run.GetRunLength()*sizeof(bool));
       // Don't allow hyphen breaks at the start of the line
       aBreakBefore[runOffsetInSubstring] = allowHyphenBreakBeforeNextChar &&
           (!(mFrame->GetStateBits() & TEXT_START_OF_LINE) ||
            run.GetSkippedOffset() > mStart.GetSkippedOffset());
       allowHyphenBreakBeforeNextChar = false;
     }
   }
 
@@ -6309,17 +6309,17 @@ ClusterIterator::ClusterIterator(nsTextF
   mTrimmed = aTextFrame->GetTrimmedOffsets(mFrag, true);
 
   PRInt32 textOffset = aTextFrame->GetContentOffset();
   PRInt32 textLen = aTextFrame->GetContentLength();
   if (!mWordBreaks.AppendElements(textLen + 1)) {
     mDirection = 0; // signal failure
     return;
   }
-  memset(mWordBreaks.Elements(), false, textLen + 1);
+  memset(mWordBreaks.Elements(), false, (textLen + 1)*sizeof(bool));
   PRInt32 textStart;
   if (aDirection > 0) {
     if (aContext.IsEmpty()) {
       // No previous context, so it must be the start of a line or text run
       mWordBreaks[0] = true;
     }
     textStart = aContext.Length();
     mFrag->AppendTo(aContext, textOffset, textLen);