The default bug view has changed. See this FAQ.

Uninitialized variable in ParamTraits<LogData>::Read

RESOLVED FIXED in mozilla17

Status

()

Core
IPC
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: Ehsan, Assigned: Ehsan)

Tracking

Trunk
mozilla17
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
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.
(Assignee)

Comment 1

5 years ago
Created attachment 646147 [details] [diff] [review]
Patch (v1)
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+
(Assignee)

Comment 3

5 years ago
http://hg.mozilla.org/integration/mozilla-inbound/rev/36eabc9af937
Target Milestone: --- → mozilla17
(Assignee)

Comment 4

5 years ago
https://hg.mozilla.org/mozilla-central/rev/36eabc9af937
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.