mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 479057 Concatenating empty strings can result in bogus copying r=bsmedberg
This commit is contained in:
parent
c07aefc948
commit
e2e4ed438f
@ -434,8 +434,17 @@ nsTSubstring_CharT::Assign( const substring_tuple_type& tuple )
|
||||
|
||||
size_type length = tuple.Length();
|
||||
|
||||
if (ReplacePrep(0, mLength, length) && length)
|
||||
// don't use ReplacePrep here because it changes the length
|
||||
char_type* oldData;
|
||||
PRUint32 oldFlags;
|
||||
if (MutatePrep(length, &oldData, &oldFlags)) {
|
||||
if (oldData)
|
||||
::ReleaseData(oldData, oldFlags);
|
||||
|
||||
tuple.WriteTo(mData, length);
|
||||
mData[length] = 0;
|
||||
mLength = length;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -552,17 +552,18 @@ PRBool test_concat_2()
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
PRBool test_concat_3()
|
||||
{
|
||||
nsCString a("a"), b("b");
|
||||
nsCString result;
|
||||
nsCString ab("ab"), c("c");
|
||||
|
||||
// THIS DOES NOT COMPILE
|
||||
const nsACString& r = a + b;
|
||||
result = ab + result + c;
|
||||
if (strcmp(result.get(), "abc") == 0)
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_TRUE;
|
||||
printf("[result=%s]\n", result.get());
|
||||
return PR_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
PRBool test_xpidl_string()
|
||||
{
|
||||
@ -997,6 +998,7 @@ tests[] =
|
||||
{ "test_fixed_string", test_fixed_string },
|
||||
{ "test_concat", test_concat },
|
||||
{ "test_concat_2", test_concat_2 },
|
||||
{ "test_concat_3", test_concat_3 },
|
||||
{ "test_xpidl_string", test_xpidl_string },
|
||||
{ "test_empty_assign", test_empty_assign },
|
||||
{ "test_set_length", test_set_length },
|
||||
|
Loading…
Reference in New Issue
Block a user