uninitialized memory in gfx/2d/SourceSurfaceCG.cpp

RESOLVED FIXED in mozilla9

Status

()

Core
Graphics
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: David Volgyes, Assigned: Atul Aggarwal)

Tracking

(Blocks: 1 bug)

Trunk
mozilla9
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20100101 Firefox/6.0
Build ID: 20110812233755

Steps to reproduce:

cppcheck found this uninitialized memory problem in the code.


Actual results:

in gfx/2d/SourceSurfaceCG.cpp in InitFromData(...) at line #113:

  void *data = malloc(aStride * aSize.height);
  memcpy(aData, data, aStride * aSize.height);

Well, the problem is that:
if you would like copy from data to aData, then data is uninitialized.
(Use calloc, or a memset befopre the copy, etc.)
If you would like copy from aData to data, then the order is wrong.


Expected results:

Fix this uninitialized data problem.

Updated

6 years ago
Blocks: 679417

Updated

6 years ago
Component: General → Graphics
Product: Firefox → Core
QA Contact: general → thebes

Comment 1

6 years ago
This is supposed to read memcpy(data, aData, aStride * aSize.height). Is this code actually used? I am amazed this hasn't been noticed before.

Updated

6 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: [good first bug] [mentor=jdm]
(Assignee)

Comment 2

6 years ago
Created attachment 556387 [details] [diff] [review]
v1 patch to swap data and aData variable.

This is my patch to mozilla. Please let me know if I am missing something.
Attachment #556387 - Flags: review?
(Assignee)

Updated

6 years ago
Attachment #556387 - Flags: review? → review?(josh)

Updated

6 years ago
Attachment #556387 - Flags: review?(josh) → review?(jmuizelaar)
This code is not actually used at this point. As a matter of fact, it isn't even compiled, and it wouldn't compile if you tried to compile it :).
Attachment #556387 - Flags: review?(jmuizelaar) → review+
Assignee: nobody → atulagrwl
Status: NEW → ASSIGNED
Flags: in-testsuite-
Keywords: checkin-needed
OS: Linux → All
Hardware: x86_64 → All
In my queue :-)
Keywords: checkin-needed
http://hg.mozilla.org/integration/mozilla-inbound/rev/5565603c0b7d
Target Milestone: --- → mozilla9
http://hg.mozilla.org/mozilla-central/rev/5565603c0b7d

Thanks Atul :-)
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Clearing good first bug status to get this off the good first bug buglist!
Whiteboard: [good first bug] [mentor=jdm]
You need to log in before you can comment on or make changes to this bug.