This is an archive of the discontinued LLVM Phabricator instance.

Fix infinite loop when ::new or ::delete are found in member initializer list
ClosedPublic

Authored by d.zobnin.bugzilla on Jan 15 2016, 2:45 AM.

Details

Summary

Fix for a case found by fuzzing PR23057 (comment #33 https://llvm.org/bugs/show_bug.cgi?id=23057#c33). Diagnose and consume unexpected ::new and ::delete tokens to prevent infinite loop in parsing a member initializer list.

Diff Detail

Repository
rL LLVM

Event Timeline

d.zobnin.bugzilla retitled this revision from to Fix infinite loop when ::new or ::delete are found in member initializer list.
d.zobnin.bugzilla updated this object.
d.zobnin.bugzilla added reviewers: kcc, rsmith.
d.zobnin.bugzilla added a subscriber: cfe-commits.
rsmith edited edge metadata.Jan 15 2016, 11:13 AM

This isn't quite the right way to fix this issue.

lib/Parse/ParseDeclCXX.cpp
3206–3209 ↗(On Diff #44971)

This is the right place to fix the bug. We should not enter this codepath if the previous initializer was not valid, and should instead fall into the else below to skip the rest of the initializers. (Delete the else { so that MemInit is still in scope here, and don't enter this block if MemInit.isInvalid(). Please also suppress the err_expected_either diagnostic below in that case.)

d.zobnin.bugzilla edited edge metadata.

Thank you for the review! Updated the patch: parser now skips the rest of the initializers if the previous one was invalid, added several checks to the test.

rsmith accepted this revision.Jan 19 2016, 2:15 PM
rsmith edited edge metadata.

LGTM, thanks! Do you need someone to commit for you?

This revision is now accepted and ready to land.Jan 19 2016, 2:15 PM

I am going to ask @ABataev to commit this. Hope to get commit access soon (this is my 5th patch) :)

This revision was automatically updated to reflect the committed changes.