Closed Bug 322908 Opened 19 years ago Closed 19 years ago

ASSERTION: NS_Alloc of size 0: 'size'

Categories

(Core :: XPCOM, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9alpha1

People

(Reporter: martijn.martijn, Assigned: darin.moz)

References

()

Details

(Keywords: assertion, testcase)

Attachments

(1 file, 1 obsolete file)

In an updated trunk build, I get this assertion when clicking on the submit button in the testcase: ###!!! ASSERTION: NS_Alloc of size 0: 'size', file c:/mozilla/mozilla/xpcom/base /nsMemoryImpl.cpp, line 335 I don't get this with a debug build from a few weeks earlier.
This is fallout from bug 318193 -- the form code is calling NS_NewByteInputStream and passing it an empty string (which seems perfectly reasonable). nsStringInputStream::SetData then calls NS_Alloc with the length of the string, which is 0. That seems wrong, but I'm not sure what the right thing to do would be; we can't use null for the data.
Assignee: nobody → dougt
Component: Layout: Form Controls → XPCOM
Flags: blocking1.9a1?
OS: Windows XP → All
QA Contact: layout.form-controls → xpcom
Hardware: PC → All
Assignee: dougt → darin
Blocks: 318193
The MSDN documentation for malloc says the following: "If size is 0, malloc allocates a zero-length item in the heap and returns a valid pointer to that item." So, why is NS_Alloc asserting that size should not be zero? I think the assertion is bogus.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.9alpha
Attached patch v1 patch (obsolete) — Splinter Review
Remove bogus assertions: malloc(0) and realloc(ptr, 0) are both valid.
Attachment #208096 - Flags: review?(benjamin)
Attached patch v1.1 patchSplinter Review
Whoops.. we shouldn't be calling FlushMemory if NS_Realloc was used to free memory!
Attachment #208096 - Attachment is obsolete: true
Attachment #208097 - Flags: review?(benjamin)
Attachment #208096 - Flags: review?(benjamin)
Attachment #208097 - Flags: review?(benjamin) → review+
fixed-on-trunk
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
Flags: blocking1.9a1?
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: