diff --git a/mozilla/string/src/nsSharableString.cpp b/mozilla/string/src/nsSharableString.cpp index 809b7c18f91..53f4b5a20f0 100644 --- a/mozilla/string/src/nsSharableString.cpp +++ b/mozilla/string/src/nsSharableString.cpp @@ -124,8 +124,9 @@ nsSharableString::do_AssignFromReadable( const abstract_string_type& aReadable ) { // null-check |mBuffer.get()| here only for the constructor // taking |const abstract_string_type&| + size_type inLength; if ( mBuffer.get() && !mBuffer->IsShared() && - mBuffer->StorageLength() > aReadable.Length() && + mBuffer->StorageLength() > (inLength = aReadable.Length()) && !aReadable.IsDependentOn(*this) ) { abstract_string_type::const_iterator fromBegin, fromEnd; @@ -133,6 +134,7 @@ nsSharableString::do_AssignFromReadable( const abstract_string_type& aReadable ) *copy_string( aReadable.BeginReading(fromBegin), aReadable.EndReading(fromEnd), storage_start ) = char_type(0); + mBuffer->DataEnd(storage_start + inLength); return; // don't want to assign to |mBuffer| below } else @@ -268,8 +270,9 @@ nsSharableCString::do_AssignFromReadable( const abstract_string_type& aReadable { // null-check |mBuffer.get()| here only for the constructor // taking |const abstract_string_type&| + size_type inLength; if ( mBuffer.get() && !mBuffer->IsShared() && - mBuffer->StorageLength() > aReadable.Length() && + mBuffer->StorageLength() > (inLength = aReadable.Length()) && !aReadable.IsDependentOn(*this) ) { abstract_string_type::const_iterator fromBegin, fromEnd; @@ -277,6 +280,7 @@ nsSharableCString::do_AssignFromReadable( const abstract_string_type& aReadable *copy_string( aReadable.BeginReading(fromBegin), aReadable.EndReading(fromEnd), storage_start ) = char_type(0); + mBuffer->DataEnd(storage_start + inLength); return; // don't want to assign to |mBuffer| below } else diff --git a/mozilla/xpcom/string/src/nsSharableString.cpp b/mozilla/xpcom/string/src/nsSharableString.cpp index 809b7c18f91..53f4b5a20f0 100644 --- a/mozilla/xpcom/string/src/nsSharableString.cpp +++ b/mozilla/xpcom/string/src/nsSharableString.cpp @@ -124,8 +124,9 @@ nsSharableString::do_AssignFromReadable( const abstract_string_type& aReadable ) { // null-check |mBuffer.get()| here only for the constructor // taking |const abstract_string_type&| + size_type inLength; if ( mBuffer.get() && !mBuffer->IsShared() && - mBuffer->StorageLength() > aReadable.Length() && + mBuffer->StorageLength() > (inLength = aReadable.Length()) && !aReadable.IsDependentOn(*this) ) { abstract_string_type::const_iterator fromBegin, fromEnd; @@ -133,6 +134,7 @@ nsSharableString::do_AssignFromReadable( const abstract_string_type& aReadable ) *copy_string( aReadable.BeginReading(fromBegin), aReadable.EndReading(fromEnd), storage_start ) = char_type(0); + mBuffer->DataEnd(storage_start + inLength); return; // don't want to assign to |mBuffer| below } else @@ -268,8 +270,9 @@ nsSharableCString::do_AssignFromReadable( const abstract_string_type& aReadable { // null-check |mBuffer.get()| here only for the constructor // taking |const abstract_string_type&| + size_type inLength; if ( mBuffer.get() && !mBuffer->IsShared() && - mBuffer->StorageLength() > aReadable.Length() && + mBuffer->StorageLength() > (inLength = aReadable.Length()) && !aReadable.IsDependentOn(*this) ) { abstract_string_type::const_iterator fromBegin, fromEnd; @@ -277,6 +280,7 @@ nsSharableCString::do_AssignFromReadable( const abstract_string_type& aReadable *copy_string( aReadable.BeginReading(fromBegin), aReadable.EndReading(fromEnd), storage_start ) = char_type(0); + mBuffer->DataEnd(storage_start + inLength); return; // don't want to assign to |mBuffer| below } else