Closed Bug 532108 Opened 15 years ago Closed 15 years ago

Null pointer dereference or redundant check in mailnews/mime/src/mimei.cpp.

Categories

(MailNews Core :: MIME, defect)

defect
Not set
minor

Tracking

(thunderbird3.0 .2-fixed)

RESOLVED FIXED
Thunderbird 3.1a1
Tracking Status
thunderbird3.0 --- .2-fixed

People

(Reporter: adam.buchbinder, Assigned: adam.buchbinder)

Details

(Keywords: fixed-seamonkey2.0.4)

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20091109 Ubuntu/9.10 (karmic) Firefox/3.5.5
Build Identifier: thunderbird-3.0rc1

cppcheck, a static code analysis tool, reported:

[comm-1.9.1/mailnews/mime/src/mimei.cpp:1502]: (error) Possible null pointer dereference: options - otherwise it is redundant to check if options is null at line 1505

Reproducible: Always




In mime_parse_url_options(), the 'options' argument is a pointer. It's used by calling "options->headers" before being checked with "if (!options)". If it's expected that options could be null, the assignment to default_headers should be moved below the check; if it's can never be null, the check is redundant and can be removed.

Either way, the test as it stands does nothing; if 'options' is null, it will simply lead to a null pointer reference and subsequent crash.

I'm marking this as minor, because I haven't been able to generate an actual crash. Please advise if I should mark this sort of issue with a different severity.
Component: General → MIME
Product: Thunderbird → MailNews Core
QA Contact: general → mime
OS: Linux → All
Hardware: x86 → All
I've used the simplest change; the assignment now occurs after the check, so it's safe against 'options' being null.
Attachment #419718 - Flags: superreview?(bugzilla)
Attachment #419718 - Flags: review?(bienvenu)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 419718 [details] [diff] [review]
Patch to move the assignment below the check.

thx for the patch, Adam - mozilla style would be to move the declaration to be with the assignment, instead of splitting them up. r=me with that change.
Attachment #419718 - Flags: review?(bienvenu) → review-
Edited the patch so that the assignment is together with the declaration, per Mozilla style.
Assignee: nobody → adam.buchbinder
Attachment #419718 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #419902 - Flags: superreview?(bugzilla)
Attachment #419902 - Flags: review?(bienvenu)
Attachment #419718 - Flags: superreview?(bugzilla)
Attachment #419902 - Flags: review?(bienvenu) → review+
Comment on attachment 419902 [details] [diff] [review]
Move the assignment below the check
[Checkin: Comment 5 & 7]

thx, Adam.
Attachment #419902 - Flags: superreview?(bugzilla) → superreview+
Keywords: checkin-needed
Comment on attachment 419902 [details] [diff] [review]
Move the assignment below the check
[Checkin: Comment 5 & 7]


http://hg.mozilla.org/comm-central/rev/3ed8bb7b219b
Attachment #419902 - Attachment description: Patch to move the assignment below the check. → Move the assignment below the check [Checkin: Comment 5]
Attachment #419902 - Flags: approval-thunderbird3.0.1?
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Flags: in-testsuite-
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → Thunderbird 3.1a1
Version: unspecified → Trunk
Comment on attachment 419902 [details] [diff] [review]
Move the assignment below the check
[Checkin: Comment 5 & 7]

We're not seeing any crashers in this area currently. We've already got a significant amount for 3.0.1 so I don't want to add this as well even thought it may be small.
Attachment #419902 - Flags: approval-thunderbird3.0.2?
Attachment #419902 - Flags: approval-thunderbird3.0.1?
Attachment #419902 - Flags: approval-thunderbird3.0.1-
Attachment #419902 - Flags: approval-thunderbird3.0.2? → approval-thunderbird3.0.2+
Attachment #419902 - Attachment description: Move the assignment below the check [Checkin: Comment 5] → Move the assignment below the check [Checkin: Comment 5 & 7]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: