This is an archive of the discontinued LLVM Phabricator instance.

Fix bug 20125 - clang-format segfaults on bad config
ClosedPublic

Authored by lifted on Aug 4 2014, 8:23 AM.

Details

Reviewers
rafael
Summary

http://llvm.org/bugs/show_bug.cgi?id=20125

The problem was in unchecked dyn_cast inside of Input::createHNodes.

E.g. the following YAML code

{ColumnLimit: 80; UseTab: Never}

is parsed as

{ {'ColumnLimit': '80; UseTab'} : 'Never' }

But the parser expected that mapping key is always a scalar. Unchecked cast of MappingNode to ScalarNode caused segfault later.

The cast is now checked, the example below produces the following error:

YAML:1:2: error: Map key must be a scalar
{ColumnLimit: 80; UseTab: Never}
 ^

Diff Detail

Event Timeline

lifted updated this revision to Diff 12162.Aug 4 2014, 8:23 AM
lifted retitled this revision from to Fix bug 20125 - clang-format segfaults on bad config.
lifted updated this object.
lifted edited the test plan for this revision. (Show Details)
lifted added a reviewer: rafael.
lifted updated this object.Aug 4 2014, 8:32 AM
lifted added a subscriber: Unknown Object (MLST).Aug 4 2014, 9:40 AM

It'll be great if you could add a test case.

lifted updated this revision to Diff 12187.EditedAug 4 2014, 10:40 PM

Added a unit test. The unit test crashes without a corresponding fix.

rafael accepted this revision.Aug 7 2014, 12:50 PM
rafael edited edge metadata.

lgtm

This revision is now accepted and ready to land.Aug 7 2014, 12:50 PM

Could you please commit the patch?