Closed Bug 562926 Opened 14 years ago Closed 14 years ago

detachAttachmentsWOPrompts crashes with zero counts [@ nsMessenger::DetachAttachmentsWOPrompts(nsIFile*, unsigned int, char const**, char const**, char const**, char const**, nsIUrlListener*)]

Categories

(MailNews Core :: Attachments, defect)

x86
Windows XP
defect
Not set
critical

Tracking

(Not tracked)

RESOLVED FIXED
Thunderbird 3.3a2

People

(Reporter: rkent, Assigned: Bienvenu)

Details

(Keywords: crash, stackwanted)

Crash Data

Attachments

(1 file)

If you call detachAttachmentsWOPrompts with empty arrays, it crashes.
Severity: normal → critical
Keywords: crash, stackwanted
Re "stackwanted" - this is a new function (that I added), and has no current use in the core code. So to make it crash, you need to call it from an extension. I did that in my FiltaQuilla extension, and discovered this issue. Because I know the issue, I can prevent it in my extension. But it should be fixed in core, and the fix is trivial.
i mostly need a stack signature in the summary in case someone does trigger it.
Summary: detachAttachmentsWOPrompts crashes with zero counts → detachAttachmentsWOPrompts crashes with zero counts [@ nsMessenger::DetachAttachmentsWOPrompts]
Kent, could you generate a crash report fur us? (or the patch)
(not seen in crash stats of last few weeks)
http://crash-stats.mozilla.com/report/index/d13babdf-a757-41a4-9e41-9d19b2110111

I generated this by removing the zero-length attachment list check from FiltaQuilla. This fix is just to return from the C++ method immediately if the attachment count is zero.
yup - yours are the only 2 crashes in 8 months
Summary: detachAttachmentsWOPrompts crashes with zero counts [@ nsMessenger::DetachAttachmentsWOPrompts] → detachAttachmentsWOPrompts crashes with zero counts [@ nsMessenger::DetachAttachmentsWOPrompts(nsIFile*, unsigned int, char const**, char const**, char const**, char const**, nsIUrlListener*)]
Attached patch correctness fixSplinter Review
since this is an idl method, it should be checking its args...
Assignee: kent → bienvenu
Attachment #503155 - Flags: review?(kent)
The only thing that I might take issue with is the error return if the count is zero. That is, if I have a list of zero attachments and ask to detach them, then doing nothing is the proper response, so why do I need an error? That just forces me to check in js whether the count is zero before using this routine, or surround it with a try block.

But that is a fairly minor point in a fairly minor patch, so rather than churn this needlessly I'll just approve it, and let you decide whether to return NS_OK or not with a count of zero.

The other issue is that you seem to be missing the check for null aDisplayNameArray. r=me with that fixed.
Attachment #503155 - Flags: review?(kent) → review+
(In reply to comment #7)
> The only thing that I might take issue with is the error return if the count is
> zero. That is, if I have a list of zero attachments and ask to detach them,
> then doing nothing is the proper response, so why do I need an error? That just
> forces me to check in js whether the count is zero before using this routine,
> or surround it with a try block.

For your use case, ignoring that error would be more convenient for you, but for other use cases, it would probably be a sign of a coding error, which is why I made it an error. But I don't care much, and I do hate js exceptions :-)
fixed on trunk - http://hg.mozilla.org/comm-central/rev/1bd4ab0795c1
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 3.3a2
Crash Signature: [@ nsMessenger::DetachAttachmentsWOPrompts(nsIFile*, unsigned int, char const**, char const**, char const**, char const**, nsIUrlListener*)]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: