Closed Bug 1289780 Opened 7 years ago Closed 7 years ago

[Static analysis][Uninitialized scalar field] In constructors nsReferencedElement & nsNameSpaceEntry

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: paul.bignier, Assigned: paul.bignier)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: [CID 750495 & 750514])

Attachments

(1 file, 1 obsolete file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20160608174051

Steps to reproduce:

See attached patch.
Keywords: coverity
Whiteboard: [Coverity 750495 & 750514]
Attachment #8775135 - Flags: review?(bzbarsky)
Comment on attachment 8775135 [details] [diff] [review]
0001-Static-analysis-Uninitialized-scalar-field-In-constr.patch

>+  nsReferencedElement() : mReferencingImage(false) {}

Three lines, please:

    nsReferencedElement()
      : mReferencingImage(false)
    {}

>+      nameSpaceID(0),

No, that's not ok.  0 is a perfectly valid namespace id (kNamespaceID_None).

But also, why do you really need this?  The namespace id is always assigned in the one place nsNameSpaceEntry is allocated: nsXMLNameSpaceMap::AddPrefix?

I guess I would be ok with initializing to kNameSpaceID_Unknown if we do want to initialize in the constructor, though.  r=me with that.
Attachment #8775135 - Flags: review?(bzbarsky) → review+
> The namespace id is always assigned in the one place nsNameSpaceEntry is allocated: nsXMLNameSpaceMap::AddPrefix?

Thanks, I hadn't noticed that, AddPrefix() wasn't intuitive enough so I didn't suspect it being in Create().
Replaced with the moz_init_outside_ctor tag.
Paul
Attachment #8775176 - Flags: review?(bzbarsky)
Comment on attachment 8775176 [details] [diff] [review]
0001-Static-analysis-Uninitialized-scalar-field-In-constr.patch

r=me
Attachment #8775176 - Flags: review?(bzbarsky) → review+
Assignee: nobody → paul.bignier
Whiteboard: [Coverity 750495 & 750514] → [CID 750495 & 750514]
Component: Untriaged → DOM
Product: Firefox → Core
Attachment #8775135 - Attachment is obsolete: true
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/563d80710d40
[Static analysis][Uninitialized scalar field] In constructors nsReferencedElement & nsNameSpaceEntry. r=bz
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/563d80710d40
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.