Last Comment Bug 581473 - possible uninitialized variable use in XPCConvert::JSData2Native
: possible uninitialized variable use in XPCConvert::JSData2Native
Product: Core
Classification: Components
Component: XPConnect (show other bugs)
: Trunk
: x86 Linux
-- normal (vote)
: mozilla9
Assigned To: Atul Aggarwal
: Andrew Overholt [:overholt]
Depends on:
Blocks: buildwarning
  Show dependency treegraph
Reported: 2010-07-23 09:56 PDT by Josh Matthews [:jdm]
Modified: 2011-09-27 03:38 PDT (History)
5 users (show)
emorley: in‑testsuite-
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

Patch v1 to fix warning (1.13 KB, patch)
2011-08-31 12:38 PDT, Atul Aggarwal
no flags Details | Diff | Splinter Review
Patch v2 (1.12 KB, patch)
2011-09-25 11:49 PDT, Atul Aggarwal
mrbkap: review+
Details | Diff | Splinter Review

Description User image Josh Matthews [:jdm] 2010-07-23 09:56:07 PDT
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
Comment 1 User image Boris Zbarsky [:bz] (still a bit busy) 2010-07-23 13:05:59 PDT
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?
Comment 2 User image Atul Aggarwal 2011-08-31 12:38:58 PDT
Created attachment 557279 [details] [diff] [review]
Patch v1 to fix warning

Please note I could not test this patch.
Comment 3 User image Blake Kaplan (:mrbkap) 2011-09-06 16:55:59 PDT
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.
Comment 4 User image Atul Aggarwal 2011-09-25 11:49:17 PDT
Created attachment 562313 [details] [diff] [review]
Patch v2

Change suggested by reviewer.
Comment 5 User image Daniel Holbert [:dholbert] 2011-09-26 15:02:43 PDT
Comment 6 User image Ed Morley [:emorley] 2011-09-27 03:38:13 PDT

Note You need to log in before you can comment on or make changes to this bug.