Malloc of 0 - nsMsgDBView.cpp

VERIFIED FIXED

Status

MailNews Core
Backend
--
critical
VERIFIED FIXED
17 years ago
10 years ago

People

(Reporter: mkaply, Assigned: Scott MacGregor)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

17 years ago
This code:

http://lxr.mozilla.org/seamonkey/source/mailnews/base/src/nsMsgDBView.
cpp#2206

Is bad.

for empty folders, arraySize is 0, so not only does a malloc of 0 
happen, but lots of unnecessary code is traversed.

I am not sure what the right thing is to do here - possibly just 
return NS_OK if arraySize is 0?
(Reporter)

Updated

17 years ago
OS: other → All
Hardware: Other → All
(Reporter)

Comment 1

17 years ago
Created attachment 43169 [details] [diff] [review]
Three View cases - return if there are no items to sort
(Reporter)

Comment 2

17 years ago
I've attached a fix for this.

On OS/2 we were asserting all over the place on the 0 mallocs.

This fixes all of our problems, and gives the same behavior as before.

To test, go to an empty folder and try all the different sorts, as 
well as threaded view. everything should work as before.
(Reporter)

Comment 3

17 years ago
Without this fix, mail is unstable on OS/2.

The 0 mallocs causes us to get "Unknown error" popups and random 
crashes on release builds.

I need this fix.
Severity: normal → critical
(Assignee)

Comment 4

17 years ago
Mike, do you want me to check this patch in or do you want to?

sr=mscott either way. 

although I prefer the if (!foo) notation insead of if (foo == 0). Either way
though. 
(Reporter)

Comment 5

17 years ago
I'll check it in, no prob, and I'll fix the syntax.

Do you definitely agree that this is the right thing to do (return NS_OK if 
there is nothing to sort)
(Assignee)

Comment 6

17 years ago
yup, I agree that it's the right thing to do. 
(Reporter)

Comment 7

17 years ago
Fix checked in
Status: NEW → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → FIXED
QA Contact: esther → stephend
verified fixed via code inspection (using LXR).
Status: RESOLVED → VERIFIED
Product: MailNews → Core
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.