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:
dbaron%fas.harvard.edu
2001-12-03 03:54:32 +00:00
parent 9758414022
commit 77c606ffad
2 changed files with 12 additions and 4 deletions

View File

@@ -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