This is an archive of the discontinued LLVM Phabricator instance.

Fix compiler crash in AsmParser::Lex
ClosedPublic

Authored by alexandru.guduleasa on Jun 7 2017, 7:08 AM.

Details

Summary

When an empty comment is present in an assembly file, the compiler will crash because it checks the first character for '\n' or '\r'.
The fix consists of also checking if the string is empty before accessing the *front* method of the StringRef.
A test is included for the x86 target, but this issue is reproducible with other targets as well.

Diff Detail

Repository
rL LLVM

Event Timeline

niravd accepted this revision.Jun 7 2017, 7:52 AM

"AsmParser::parseStatement" also has this issue. Please add the fix there as part of your commit as well?

Modulo that, LGTM.

lib/MC/MCParser/AsmParser.cpp
703

Nit: Please use !getTok().getString().empty()

This revision is now accepted and ready to land.Jun 7 2017, 7:52 AM

Updated as per comments.

niravd added a comment.Jun 9 2017, 6:24 AM

Looks good. Do you have commit access or would you like someone to commit this patch for you?

Thank you for the review.
I do not have commit access; I would appreciate it if someone can commit this.

This revision was automatically updated to reflect the committed changes.