Closed Bug 1472672 Opened 2 years ago Closed 2 years ago

[Static Analysis] Possible null-dereference in nsMaiInterfaceText.cpp

Categories

(Core :: Disability Access APIs, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla63
Tracking Status
firefox63 --- fixed

People

(Reporter: rbartlensky, Assigned: rbartlensky)

References

Details

Attachments

(1 file)

infer reports the following error:
accessible/atk/nsMaiInterfaceText.cpp:467: error: NULL_DEREFERENCE
  pointer `textAcc` last assigned on line 465 could be null and is dereferenced at line 467, column 7.
  465.       HyperTextAccessible* textAcc = accWrap->AsHyperText();
  466.       return
  467. >       textAcc->IsDefunct() ? 0 : static_cast<gint>(textAcc->CharacterCount());
  468.     }
  469.

https://dxr.mozilla.org/mozilla-central/source/accessible/atk/nsMaiInterfaceText.cpp#467

textAcc can be null because `AsHyperText` can return null. I have checked to see if the code that calls `getCharacterCountCB` ever ensures that `aText` is a hyper text, but it is never the case. This means that the warning is indeed true.
Attachment #8989748 - Flags: review?(dbolter)
Comment on attachment 8989748 [details]
Bug 1472672: Add null check for textAcc.

ok with me
Attachment #8989748 - Flags: review?(dbolter) → review+
Pushed by apavel@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c463161da7b4
Add null check for textAcc. r=davidb
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/c463161da7b4
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
You need to log in before you can comment on or make changes to this bug.