Page MenuHomePhabricator

[AST] Fix potential nullptr dereference in Expr::HasSideEffects
ClosedPublic

Authored by jkorous on Jul 8 2020, 3:22 PM.

Diff Detail

Event Timeline

jkorous created this revision.Jul 8 2020, 3:22 PM

I can confirm that the test case crashes without the null pointer check and passes with the check.

ckandeler accepted this revision.Jul 10 2020, 2:57 AM
This revision is now accepted and ready to land.Jul 10 2020, 2:57 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2020, 11:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

I think that adding an unittest for such a simple fix is a bit heavy handed. What about just exercising this code path. For example:

void Test(int N) {
  int arr[N];
  decltype([&arr]{}) *p; // expected-error {{lambda expression in an unevaluated operand}}
}

Sounds like a good idea.