Last Comment Bug 581473 - possible uninitialized variable use in XPCConvert::JSData2Native
: possible uninitialized variable use in XPCConvert::JSData2Native
Status: RESOLVED FIXED
[build_warning]
:
Product: Core
Classification: Components
Component: XPConnect (show other bugs)
: Trunk
: x86 Linux
: -- normal (vote)
: mozilla9
Assigned To: Atul Aggarwal
:
Mentors:
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:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


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

Description 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 Boris Zbarsky [:bz] (Out June 25-July 6) 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 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 Blake Kaplan (:mrbkap) (please use needinfo!) 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 Atul Aggarwal 2011-09-25 11:49:17 PDT
Created attachment 562313 [details] [diff] [review]
Patch v2

Change suggested by reviewer.
Comment 5 Daniel Holbert [:dholbert] (largely AFK until June 28) 2011-09-26 15:02:43 PDT
https://hg.mozilla.org/integration/mozilla-inbound/rev/9b6d23e07968
Comment 6 Ed Morley [:emorley] 2011-09-27 03:38:13 PDT
https://hg.mozilla.org/mozilla-central/rev/9b6d23e07968

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