Page MenuHomePhabricator

[libclang] Fix crash when visiting a captured VLA.

Authored by ckandeler on Jun 26 2020, 1:46 AM.



When a variable-length array is being captured in a lambda, the AST
contains two captures, the first one having a null init expression.
Visiting that one triggers an assertion, so skip it.

Diff Detail

Event Timeline

ckandeler created this revision.Jun 26 2020, 1:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2020, 1:46 AM
ckandeler updated this revision to Diff 274071.Jun 29 2020, 5:25 AM

Fixed formatting issues.

this relates to too, but comes with a test which is good. personally I would place the check directly within Visit to make it more generically prevent a crash on invalid input, but that's probably a subjective design decision.

ckandeler added a comment.EditedJul 2 2020, 12:52 AM

I suppose it boils down to whether the visit() function is supposed to accept null arguments or not. Since I don't know the answer to that, I added the check at the caller. From the description of the linked patch, it appears that other places are also calling the function with a null pointer, but that could just mean that these should be fixed independently. Someone with better knowledge of the code would have to make that decision.

jkorous accepted this revision.Jul 6 2020, 4:11 PM

LGTM! Thanks for fixing this!

This revision is now accepted and ready to land.Jul 6 2020, 4:11 PM

@ckandeler do you have commit access or do you want me to land the patch?

@ckandeler do you have commit access or do you want me to land the patch?

I do not, so it'd be great if you could do it.

This revision was automatically updated to reflect the committed changes.