Closed
Bug 282814
Opened 21 years ago
Closed 18 years ago
nsAutoBuffer::EnsureElemCapacity is broken
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
People
(Reporter: dbaron, Assigned: sharparrow1)
Details
Attachments
(1 file, 1 obsolete file)
|
2.73 KB,
patch
|
benjamin
:
review+
bzbarsky
:
approval1.9+
|
Details | Diff | Splinter Review |
nsAutoBuffer::EnsureElemCapacity is broken in 2 ways:
1) it nsMemory::Frees a pointer than has already been nsMemory::Realloced
2) It does not copy the data when it switches from stack to alloced (which the
comments imply is OK)
Note that fixing (2) costs performance -- an alternative is to document and
enforce that the capacity can only be set once.
Updated•19 years ago
|
Assignee: dougt → nobody
QA Contact: xpcom
| Assignee | ||
Comment 1•18 years ago
|
||
(In reply to comment #0)
> 2) It does not copy the data when it switches from stack to alloced (which the
> comments imply is OK)
>
> Note that fixing (2) costs performance -- an alternative is to document and
> enforce that the capacity can only be set once.
Another alternative would be to document that data isn't preserved through calls to EnsureElemCapacity; none of the current users depend on the data being preserved, but a few callers depend on being able to change the capacity multiple times.
| Assignee | ||
Comment 2•18 years ago
|
||
I think this approach is correct.
| Assignee | ||
Comment 3•18 years ago
|
||
Oops, sorry about that, I accidentally attached the wrong thing.
Attachment #278666 -
Attachment is obsolete: true
Attachment #278667 -
Flags: review?(benjamin)
Attachment #278666 -
Flags: review?(benjamin)
Comment 4•18 years ago
|
||
shouldn't you just use malloc/free/realloc here instead of nsMemory?
Comment 5•18 years ago
|
||
Comment on attachment 278667 [details] [diff] [review]
Correct patch
bonus points for changing nsMemory::Alloc and friends to NS_Alloc and friends while you're there.
Attachment #278667 -
Flags: review?(benjamin) → review+
| Assignee | ||
Updated•18 years ago
|
Attachment #278667 -
Flags: approval1.9?
Updated•18 years ago
|
Attachment #278667 -
Flags: approval1.9? → approval1.9+
| Assignee | ||
Comment 6•18 years ago
|
||
Checked in with change to NS_Alloc and friends.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•