Make nsSharableString::Assign set the length when it's reusing its existing buffer. b=112483 r=jag sr=hyatt
git-svn-id: svn://10.0.0.236/trunk@109509 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user