This is an archive of the discontinued LLVM Phabricator instance.

Avoid nullptr dereferencing of 'SubExpr'; NFC
ClosedPublic

Authored by schittir on Aug 25 2021, 10:24 AM.

Details

Summary

Avoid nullptr dereferencing of 'Constraint'; NFC

Klocwork static code analysis exposed this bug:
Pointer 'SubExpr' returned from call to getSubExpr() function
which may return NULL from 'cast_or_null<Expr>(Operand)',
which will be dereferenced in the statement following it

Add an assert on SubExpr to avoid nullptr dereferencing

Diff Detail

Event Timeline

schittir requested review of this revision.Aug 25 2021, 10:24 AM
schittir created this revision.
aaron.ballman accepted this revision.Aug 25 2021, 10:34 AM

LGTM! There is no way for this to be null because emitRethrow() is what should be called in that case.

I'll land this on your behalf sometime shortly (perhaps as late as tomorrow).

This revision is now accepted and ready to land.Aug 25 2021, 10:34 AM

LGTM! There is no way for this to be null because emitRethrow() is what should be called in that case.

I'll land this on your behalf sometime shortly (perhaps as late as tomorrow).

Thank you, Aaron!

aaron.ballman closed this revision.Aug 26 2021, 5:03 AM

I've committed on your behalf in de15979bc32d761c9b5071fb7d28d7c04ebbfaf3, thank you for the improvement!