Bug 1113005 - Copy only the necessary number of bytes from the source buffer; r=froydnj
☠☠ backed out by afd92b25e239 ☠ ☠
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 19 Dec 2014 13:12:34 -0500
changeset 246513 a6c8c4ccb5e7caffcf64b3c6ce75cae628014fa1
parent 246512 b6aba55876988ea7c5c3b0c17ebb4275984dc784
child 246514 4d9a7a26e09a5c6ba34abcaef7ca027e29aa4d7e
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1113005
milestone37.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 1113005 - Copy only the necessary number of bytes from the source buffer; r=froydnj
xpcom/string/nsTStringObsolete.cpp
--- a/xpcom/string/nsTStringObsolete.cpp
+++ b/xpcom/string/nsTStringObsolete.cpp
@@ -500,17 +500,17 @@ nsTString_CharT::ReplaceSubstring( const
 
   // Make sure that we can mutate our buffer.
   char_type* oldData;
   uint32_t oldFlags;
   if (!MutatePrep(XPCOM_MAX(mLength, newLength), &oldData, &oldFlags))
     return;
   if (oldData) {
     // Copy all of the old data to the new buffer.
-    char_traits::copy(mData, oldData, XPCOM_MAX(mLength, newLength));
+    char_traits::copy(mData, oldData, XPCOM_MIN(mLength, newLength));
     ::ReleaseData(oldData, oldFlags);
   }
 
   if (aTarget.Length() >= aNewValue.Length()) {
     // In the shrinking case, start filling the buffer from the beginning.
     const uint32_t delta = (aTarget.Length() - aNewValue.Length());
     for (i = 1; i < nonMatching.Length(); ++i) {
       // When we move the i'th non-matching segment into position, we need to