Closed
Bug 1278480
Opened 8 years ago
Closed 8 years ago
[Static Analysis][Dereference null return value] In function TouchActionHelper::GetAllowedTouchBehavior
Categories
(Core :: Graphics, defect)
Core
Graphics
Tracking
()
RESOLVED
FIXED
mozilla50
Tracking | Status | |
---|---|---|
firefox50 | --- | fixed |
People
(Reporter: andi, Assigned: andi)
References
(Blocks 1 open bug)
Details
(Keywords: coverity, Whiteboard: CID 1362528)
Attachments
(1 file)
The Static Analysis tool Coverity detected that pointer |view| be assigned a null return value: >> nsView *view = nsView::GetViewFor(aWidget); >> nsIFrame *viewFrame = view->GetFrame(); |view| should be checked with an assert before being used since in function GetFrame member variable |mFrame| will be return thus producing a null pointer dereference. >> nsView *view = nsView::GetViewFor(aWidget); >> MOZ_ASSERT(view, "view should not be null"); >> nsIFrame *viewFrame = view->GetFrame();
Assignee | ||
Comment 1•8 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/58182/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/58182/
Attachment #8760637 -
Flags: review?(jmuizelaar)
Comment 2•8 years ago
|
||
Comment on attachment 8760637 [details] Bug 1278480 - prevent null pointer dereference. I think this should either handle nullptr properly or have a comment explaining why it won't get a nullptr.
Attachment #8760637 -
Flags: review?(jmuizelaar) → review?(bugmail.mozilla)
Updated•8 years ago
|
Attachment #8760637 -
Flags: review?(bugmail.mozilla) → review-
Comment 3•8 years ago
|
||
Comment on attachment 8760637 [details] Bug 1278480 - prevent null pointer dereference. https://reviewboard.mozilla.org/r/58182/#review55068 I think in this case adding a null check would be more correct. I don't think there's any guarantee here that the view will be non-null. You can move the |TouchBehaviorFlags behavior = ...| line near the bottom of the function up to the top and return that as the value if the view is null.
Assignee | ||
Comment 4•8 years ago
|
||
Comment on attachment 8760637 [details] Bug 1278480 - prevent null pointer dereference. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/58182/diff/1-2/
Attachment #8760637 -
Flags: review- → review?(bugmail.mozilla)
Comment 5•8 years ago
|
||
Comment on attachment 8760637 [details] Bug 1278480 - prevent null pointer dereference. https://reviewboard.mozilla.org/r/58182/#review55370 ::: gfx/layers/apz/util/TouchActionHelper.cpp:54 (Diff revision 2) > nsView *view = nsView::GetViewFor(aWidget); > + TouchBehaviorFlags behavior = AllowedTouchBehavior::VERTICAL_PAN | AllowedTouchBehavior::HORIZONTAL_PAN | > + AllowedTouchBehavior::PINCH_ZOOM | AllowedTouchBehavior::DOUBLE_TAP_ZOOM; > + > + if (!view) > + return behavior; Braces around the body of the if statement, please. r+ with that.
Attachment #8760637 -
Flags: review?(bugmail.mozilla) → review+
Assignee | ||
Comment 6•8 years ago
|
||
Comment on attachment 8760637 [details] Bug 1278480 - prevent null pointer dereference. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/58182/diff/2-3/
Assignee | ||
Comment 7•8 years ago
|
||
Comment on attachment 8760637 [details] Bug 1278480 - prevent null pointer dereference. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/58182/diff/3-4/
Pushed by bpostelnicu@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/ec866ebf94bc prevent null pointer dereference. r=kats
Comment 9•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/ec866ebf94bc
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in
before you can comment on or make changes to this bug.
Description
•