Closed
Bug 1273423
Opened 9 years ago
Closed 9 years ago
[Static Analysis][Dereference after null check] In function nsNativeThemeGTK::GetGtkWidgetAndState
Categories
(Core :: Widget: Gtk, defect)
Core
Widget: Gtk
Tracking
()
RESOLVED
FIXED
mozilla51
People
(Reporter: andi, Assigned: andi)
References
(Blocks 1 open bug)
Details
(Keywords: coverity, Whiteboard: CID 1361618)
Attachments
(2 files)
The Static Analysis tool Coverity added that variable |aFrame| is null checked here:
>> if (!aFrame) {
>> // reset the entire struct to zero
>> memset(aState, 0, sizeof(GtkWidgetState));
>> } else
and dereferenced later on:
>> case NS_THEME_RANGE:
>> {
>> if (IsRangeHorizontal(aFrame)) {
>> if (aWidgetFlags)
>> *aWidgetFlags = GTK_ORIENTATION_HORIZONTAL;
>> aGtkWidgetType = MOZ_GTK_SCALE_HORIZONTAL;
>> }
this implies that a potential null pointer dereference can happen
Assignee | ||
Comment 1•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/53154/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/53154/
Attachment #8753262 -
Flags: review?(karlt)
Comment 2•9 years ago
|
||
Comment on attachment 8753262 [details]
MozReview Request: Bug 1273423 - removed useless null pointer check on |aFrame|. r?karlt+@karlt.net
https://reviewboard.mozilla.org/r/53154/#review50186
(In reply to Andi-Bogdan Postelnicu from comment #0)
> this implies that a potential null pointer dereference can happen
Either that or the null check in the first case is unnecessary
(or even that it is unnecessary when aWidgetType is NS_THEME_RANGE).
But looking through the callers, and documentation, there is no evidence that
aFrame may be null.
The null check dates back to the first version of the file [1] and I don't
think it is necessary now (if it ever was).
nsNativeThemeCocoa.mm and nsNativeThemeWin.cpp also seem to assume that aFrame
is non-null.
So I think the best fix for the inconsistency detected by Coverity is to
remove the dead code for !aFrame. Automated testing will tell us if my
analysis is incorrect.
http://52.25.115.98/viewvc/main/mozilla/widget/src/gtk2/nsNativeThemeGTK.cpp?annotate=1.32#l239
Attachment #8753262 -
Flags: review?(karlt)
Assignee | ||
Comment 3•9 years ago
|
||
Comment on attachment 8753262 [details]
MozReview Request: Bug 1273423 - removed useless null pointer check on |aFrame|. r?karlt+@karlt.net
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/53154/diff/1-2/
Attachment #8753262 -
Flags: review?(karlt)
Comment 4•9 years ago
|
||
Comment on attachment 8753262 [details]
MozReview Request: Bug 1273423 - removed useless null pointer check on |aFrame|. r?karlt+@karlt.net
https://reviewboard.mozilla.org/r/53154/#review50464
Thanks! Please update the commit message for the new change.
Attachment #8753262 -
Flags: review?(karlt) → review+
Assignee | ||
Comment 5•9 years ago
|
||
Comment on attachment 8753262 [details]
MozReview Request: Bug 1273423 - removed useless null pointer check on |aFrame|. r?karlt+@karlt.net
Review request updated; see interdiff: https://reviewboard.mozilla.org/r/53154/diff/2-3/
Attachment #8753262 -
Attachment description: MozReview Request: Bug 1273423 - prevent null pointer dereference on |aFrame|. r?karlt+@karlt.net → MozReview Request: Bug 1273423 - removed useless null pointer check on |aFrame|. r?karlt+@karlt.net
Assignee | ||
Comment 6•9 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/67956/diff/#index_header
See other reviews: https://reviewboard.mozilla.org/r/67956/
Attachment #8775966 -
Flags: review?(karlt)
Updated•9 years ago
|
Attachment #8775966 -
Flags: review?(karlt) → review+
Comment 7•9 years ago
|
||
Comment on attachment 8775966 [details]
Bug 1273423 - removed useless null pointer check on |aFrame|. +@karlt.net
https://reviewboard.mozilla.org/r/67956/#review65274
Pushed by bpostelnicu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f0727a3518c6
removed useless null pointer check on |aFrame|. r=karlt+@karlt.net
Comment 9•9 years ago
|
||
bugherder |
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox51:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Comment 10•9 years ago
|
||
Not worth uplifting it I guess
You need to log in
before you can comment on or make changes to this bug.
Description
•