Last Comment Bug 777734 - Uninitialized variable in ParamTraits<LogData>::Read
: Uninitialized variable in ParamTraits<LogData>::Read
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: IPC (show other bugs)
: Trunk
: x86_64 Linux
: -- normal (vote)
: mozilla17
Assigned To: :Ehsan Akhgari
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-26 08:23 PDT by :Ehsan Akhgari
Modified: 2012-07-27 09:01 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Patch (v1) (963 bytes, patch)
2012-07-26 08:25 PDT, :Ehsan Akhgari
cjones.bugs: review+
Details | Diff | Splinter Review

Description :Ehsan Akhgari 2012-07-26 08:23:49 PDT
See http://mxr.mozilla.org/mozilla-central/source/ipc/chromium/src/chrome/common/ipc_message_utils.h#801

If the one of the first two ReadParam calls returns false, type will be used uninitialized, which seems bad.

/media/storage/moz/mozilla-inbound/ipc/chromium/src/chrome/common/ipc_message_utils.h:799:7: warning: variable 'type' is used uninitialized
      whenever '&&' condition is false [-Wsometimes-uninitialized]
      ReadParam(m, iter, &r->channel) &&
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/storage/moz/mozilla-inbound/ipc/chromium/src/chrome/common/ipc_message_utils.h:807:35: note: uninitialized use occurs here
    r->type = static_cast<uint16>(type);
                                  ^~~~
/media/storage/moz/mozilla-inbound/ipc/chromium/src/chrome/common/ipc_message_utils.h:799:7: note: remove the '&&' if its condition is
      always true
      ReadParam(m, iter, &r->channel) &&
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/storage/moz/mozilla-inbound/ipc/chromium/src/chrome/common/ipc_message_utils.h:799:7: warning: variable 'type' is used uninitialized
      whenever '&&' condition is false [-Wsometimes-uninitialized]
      ReadParam(m, iter, &r->channel) &&
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/storage/moz/mozilla-inbound/ipc/chromium/src/chrome/common/ipc_message_utils.h:807:35: note: uninitialized use occurs here
    r->type = static_cast<uint16>(type);
                                  ^~~~
/media/storage/moz/mozilla-inbound/ipc/chromium/src/chrome/common/ipc_message_utils.h:799:7: note: remove the '&&' if its condition is
      always true
      ReadParam(m, iter, &r->channel) &&
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/media/storage/moz/mozilla-inbound/ipc/chromium/src/chrome/common/ipc_message_utils.h:797:13: note: initialize the variable 'type' to
      silence this warning
    int type;
            ^
             = 0
2 warnings generated.
Comment 1 :Ehsan Akhgari 2012-07-26 08:25:08 PDT
Created attachment 646147 [details] [diff] [review]
Patch (v1)
Comment 2 Chris Jones [:cjones] inactive; ni?/f?/r? if you need me 2012-07-26 10:12:38 PDT
Comment on attachment 646147 [details] [diff] [review]
Patch (v1)

The uninitialized type won't cause problems because failed Read() prevents dispatch, but silencing the warning makes sense.

Note: message 0 will refer to a valid message, but per above it doesn't matter, we won't try to dispatch with bogus data.

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