possible uninitialized variable use in XPCConvert::JSData2Native

RESOLVED FIXED in mozilla9

Status

()

Core
XPConnect
RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: jdm, Assigned: Atul Aggarwal)

Tracking

(Blocks: 1 bug)

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

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [build_warning])

Attachments

(1 attachment, 1 obsolete attachment)

(Reporter)

Description

7 years ago
js/src/xpconnect/src/xpcconvert.cpp: In static member function ‘static JSBool XPCConvert::JSData2Native(XPCCallContext&, void*, jsval, const nsXPTType&, JSBool, const nsID*, nsresult*)':
js/src/xpconnect/src/xpcconvert.cpp:683: warning: ‘chars’ may be used uninitialized in this function
js/src/xpconnect/src/xpcconvert.cpp:686: warning: ‘length’ may be used uninitialized in this function
This is your typical "gcc's flow analysis is broken" warning.  The code that looks like this:

  if (JSVAL_IS_VOID(s)) {
    ...
  } else if (!JSVAL_IS_NULL(s)) {
  }

initializes length and chars in all cases except JSVAL_IS_NULL(s).  Then below that the codepaths that use str and chars are guarded so that we don't take them when JSVAL_IS_NULL(s).

Is there any way to silence this warning for known-good code?
(Reporter)

Updated

7 years ago
Whiteboard: [build_warning]

Updated

6 years ago
Blocks: 187528
(Assignee)

Comment 2

6 years ago
Created attachment 557279 [details] [diff] [review]
Patch v1 to fix warning

Please note I could not test this patch.
Assignee: nobody → atulagrwl
Status: NEW → ASSIGNED
(Assignee)

Updated

6 years ago
Attachment #557279 - Flags: review?(mrbkap)
Comment on attachment 557279 [details] [diff] [review]
Patch v1 to fix warning

Since we should never use this value, I'd prefer to initialize chars to nsnull here so we'll crash if we accidentally do use it. I'll r+ a patch with that change.
Attachment #557279 - Flags: review?(mrbkap)
(Assignee)

Comment 4

6 years ago
Created attachment 562313 [details] [diff] [review]
Patch v2

Change suggested by reviewer.
Attachment #557279 - Attachment is obsolete: true
Attachment #562313 - Flags: review?(mrbkap)

Updated

6 years ago
Attachment #562313 - Flags: review?(mrbkap) → review+
(Assignee)

Updated

6 years ago
Keywords: checkin-needed
https://hg.mozilla.org/integration/mozilla-inbound/rev/9b6d23e07968
Keywords: checkin-needed
Whiteboard: [build_warning] → [build_warning][inbound]
Target Milestone: --- → mozilla9

Comment 6

6 years ago
https://hg.mozilla.org/mozilla-central/rev/9b6d23e07968
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Whiteboard: [build_warning][inbound] → [build_warning]
You need to log in before you can comment on or make changes to this bug.