Closed
Bug 504660
Opened 16 years ago
Closed 16 years ago
EnsureMutable(0) doesn't?
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
People
(Reporter: neil, Assigned: neil)
Details
Attachments
(1 file)
|
2.83 KB,
patch
|
benjamin
:
review+
|
Details | Diff | Splinter Review |
EnsureMutable(0) calls SetLength(0) which calls SetCapacity(0) which sets mData to sEmptyBuffer which isn't mutable.
Would it possibly be more realistic to use ReplacePrep?
if (newLen == size_type(-1) || newLen == mLength)
{
if (mFlags & (F_FIXED | F_OWNED))
return PR_TRUE;
if ((mFlags & F_SHARED) && !nsStringBuffer::FromData(mData)->IsReadonly())
return PR_TRUE;
}
if (newLen < mLength)
return ReplacePrep(0, newLen, mLength - newLen, 0);
return ReplacePrep(0, mLength, 0, newLen - mLength);
Comment 1•16 years ago
|
||
EnsureMutable(0) doesn't actually need to do anything: you can't actually mutate a 0-length string... seems to me it works as intended.
| Assignee | ||
Comment 2•16 years ago
|
||
Some functions, such as nsUnescapeCount, overwrite a zero-length string...
Comment 3•16 years ago
|
||
How does that work? Isn't that a buffer overflow?
| Assignee | ||
Comment 4•16 years ago
|
||
No, because they only want to overwrite it with another zero-length string.
Comment 5•16 years ago
|
||
So specifically they write a null terminator? I rather dislike that, but if that's the case maybe we can just make EmptyString use a non-const buffer?
| Assignee | ||
Comment 6•16 years ago
|
||
Updated•16 years ago
|
Attachment #389329 -
Flags: review?(benjamin) → review+
| Assignee | ||
Comment 7•16 years ago
|
||
Pushed changeset d347a454b338 to mozilla-central.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Seems like it's worth adding a test for this to TestStrings, since it's an odd use case.
Updated•5 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•