Closed
Bug 1297054
Opened 10 years ago
Closed 10 years ago
[Static Analysis][Dereference before null check] in function CanvasRenderingContext2D::InitializeWithDrawTarget
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
mozilla51
| Tracking | Status | |
|---|---|---|
| firefox51 | --- | fixed |
People
(Reporter: andi, Assigned: andi)
References
(Blocks 1 open bug)
Details
(Keywords: coverity, Whiteboard: CID 1368323)
Attachments
(1 file)
The Static Analysis tool Coverity detected that |aTarget| is dereferenced before begin null checked:
>> IntSize size = aTarget->GetSize();
>> SetDimensions(size.width, size.height);
>>
>> if (aTarget) {
>> mTarget = aTarget;
>> mBufferProvider = new PersistentBufferProviderBasic(aTarget);
>> } else {
>> EnsureErrorTarget();
>> mTarget = sErrorTarget;
>> }
There is no posibility that in this context a null pointer dereference can occur since the context where InitializeWithDrawTarget gets called null check aTarget:
>> RefPtr<DrawTarget> canvasTarget =
>> drawTarget->CreateSimilarDrawTarget(size, drawTarget->GetFormat());
>> if (!canvasTarget) {
>> continue;
>> }
>>
>> nsICanvasRenderingContextInternal* ctx = canvas->GetContextAtIndex(0);
>> if (!ctx) {
>> continue;
>> }
>>
>> // Initialize the context with the new DrawTarget.
>> ctx->InitializeWithDrawTarget(nullptr, canvasTarget);
| Comment hidden (mozreview-request) |
Comment 2•10 years ago
|
||
| mozreview-review | ||
Comment on attachment 8783511 [details]
Bug 1297054 - remove null check in CanvasRenderingContext2D::InitializeWithDrawTarget.
https://reviewboard.mozilla.org/r/73304/#review71192
Can you change the signature of IntializeWithDrawTarget to use NotNull<gfx::DrawTarget*> aTarget?
Comment 3•10 years ago
|
||
| mozreview-review | ||
Comment on attachment 8783511 [details]
Bug 1297054 - remove null check in CanvasRenderingContext2D::InitializeWithDrawTarget.
https://reviewboard.mozilla.org/r/73304/#review71194
Attachment #8783511 -
Flags: review?(jmuizelaar) → review-
| Comment hidden (mozreview-request) |
Comment 5•10 years ago
|
||
| mozreview-review | ||
Comment on attachment 8783511 [details]
Bug 1297054 - remove null check in CanvasRenderingContext2D::InitializeWithDrawTarget.
https://reviewboard.mozilla.org/r/73304/#review71696
Attachment #8783511 -
Flags: review?(jmuizelaar) → review+
Pushed by bpostelnicu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/97158ba1395d
remove null check in CanvasRenderingContext2D::InitializeWithDrawTarget. r=jrmuizel
Comment 7•10 years ago
|
||
| bugherder | ||
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•