dist/include/ipc/nsGUIEventIPC.h:382:7: warning: variable 'isNull' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]

RESOLVED FIXED in mozilla36

Status

()

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: dholbert, Assigned: gyeh)

Tracking

(Blocks 1 bug)

Trunk
mozilla36
x86_64
Linux
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

New build warning:
{
dist/include/ipc/nsGUIEventIPC.h:382:7: warning: variable 'isNull' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
     bool isNull;
               ^
}

This is generated code, which looks like this:
  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
  {
    bool isNull;
    bool value;
    bool rv =
      ReadParam(aMsg, aIter,
                static_cast<mozilla::WidgetKeyboardEvent*>(aResult)) &&
      ReadParam(aMsg, aIter, &isNull) &&
      ReadParam(aMsg, aIter, &value);

    aResult->mEmbeddedCancelled = Nullable<bool>();
    if (!isNull) {
      aResult->mEmbeddedCancelled.SetValue(value);
    }

    return rv;
  }


The source for this code was added here, in bug 989198:
  https://hg.mozilla.org/mozilla-central/rev/186743fc6f6d#l4.23

Basically, we need to be checking whether "rv" is true, before we read "isNull". If rv is false, then we might have failed the first ReadParam call, which means we should definitely not be reading isNull.
Flags: needinfo?(gyeh)
Good catch, Daniel  ;)

Let me fix it today. Thanks.
Flags: needinfo?(gyeh)
Assignee: nobody → gyeh
Comment on attachment 8505264 [details] [diff] [review]
Patch 1(v1): Check rv before reading isNull

As Daniel described in bug description, we should check the return value of function ReadParam() before reading the resulted value.
Attachment #8505264 - Flags: review?(bugs)
Attachment #8505264 - Flags: feedback?(dholbert)
Comment on attachment 8505264 [details] [diff] [review]
Patch 1(v1): Check rv before reading isNull

Thanks for the quick turnaround! This seems reasonable to me, and I verified that this makes clang++ satisfied such that it no longer warns about this.
Attachment #8505264 - Flags: feedback?(dholbert) → feedback+
Attachment #8505264 - Flags: review?(bugs) → review+
https://hg.mozilla.org/mozilla-central/rev/a7c972407578
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
Bug 989198 was backed out. Please remember to include this fix when it re-lands.
You need to log in before you can comment on or make changes to this bug.