Closed Bug 1273128 Opened 4 years ago Closed 3 years ago

[Static Analysis][Dereference before null check] In function nsMenuBarListener::KeyPress

Categories

(Core :: XUL, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla49
Tracking Status
firefox49 --- fixed

People

(Reporter: andi, Assigned: andi)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: CID 1361780)

Attachments

(1 file)

The Static Analysis tool Coverity added that variable |nativeKeyEvent| is derefernced before being null checked. 

dereference:

>>    // If accesskey handling was forwarded to a child process, wait for
>>    // the mozaccesskeynotfound event before handling accesskeys.
>>    WidgetKeyboardEvent* nativeKeyEvent =
>>      aKeyEvent->WidgetEventPtr()->AsKeyboardEvent();
>>    if (nativeKeyEvent->mAccessKeyForwardedToChild) {
>>      return NS_OK;
>>    }

null-check:

>>    bool hasAccessKeyCandidates = charCode != 0;
>>    if (!hasAccessKeyCandidates) {
>>      if (nativeKeyEvent) {
>>        AutoTArray<uint32_t, 10> keys;
>>        nativeKeyEvent->GetAccessKeyCandidates(keys);
>>        hasAccessKeyCandidates = !keys.IsEmpty();
>>      }
>>    }
Comment on attachment 8752817 [details]
MozReview Request: Bug 1273128 - prevent null pointer dereference on |nativeKeyEvent|. r?janv

https://reviewboard.mozilla.org/r/52804/#review51428

r=me
Attachment #8752817 - Flags: review?(jvarga) → review+
https://hg.mozilla.org/mozilla-central/rev/a2cfd126f1e5
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Component: XP Toolkit/Widgets: Menus → XUL
You need to log in before you can comment on or make changes to this bug.