Closed Bug 777734 Opened 12 years ago Closed 12 years ago

Uninitialized variable in ParamTraits<LogData>::Read

Categories

(Core :: IPC, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla17

People

(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)

Details

Attachments

(1 file)

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.
Attached patch Patch (v1)Splinter Review
Assignee: nobody → ehsan
Status: NEW → ASSIGNED
Attachment #646147 - Flags: review?(jones.chris.g)
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.
Attachment #646147 - Flags: review?(jones.chris.g) → review+
http://hg.mozilla.org/integration/mozilla-inbound/rev/36eabc9af937
Target Milestone: --- → mozilla17
https://hg.mozilla.org/mozilla-central/rev/36eabc9af937
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: