Make nsSharableString::Assign set the length correctly when it's reusing its existing buffer. b=112483 r=scc sr=alecf

git-svn-id: svn://10.0.0.236/trunk@109561 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dbaron%fas.harvard.edu
2001-12-03 23:14:15 +00:00
parent 033ce36ec4
commit 0739da3e8c
2 changed files with 8 additions and 12 deletions

View File

@@ -124,9 +124,8 @@ 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() > (inLength = aReadable.Length()) &&
mBuffer->StorageLength() > aReadable.Length() &&
!aReadable.IsDependentOn(*this) )
{
abstract_string_type::const_iterator fromBegin, fromEnd;
@@ -134,7 +133,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);
mBuffer->DataEnd(storage_start); // modified by |copy_string|
return; // don't want to assign to |mBuffer| below
}
else
@@ -270,9 +269,8 @@ 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() > (inLength = aReadable.Length()) &&
mBuffer->StorageLength() > aReadable.Length() &&
!aReadable.IsDependentOn(*this) )
{
abstract_string_type::const_iterator fromBegin, fromEnd;
@@ -280,7 +278,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);
mBuffer->DataEnd(storage_start); // modified by |copy_string|
return; // don't want to assign to |mBuffer| below
}
else