]> granicus.if.org Git - clang/commit
[Lex] Fix handling numerical literals ending with ' and signed exponent.
authorVolodymyr Sapsai <vsapsai@apple.com>
Tue, 6 Feb 2018 22:39:25 +0000 (22:39 +0000)
committerVolodymyr Sapsai <vsapsai@apple.com>
Tue, 6 Feb 2018 22:39:25 +0000 (22:39 +0000)
commit3173107098f26b3081a11432f776d70fa3545a0f
tree10b6159e355a7c79bd30c6ae58af4eeb07af5fe7
parent5203555364188d5c92fc0c0bf51a5e37f3719d87
[Lex] Fix handling numerical literals ending with ' and signed exponent.

For input `0'e+1` lexer tokenized as numeric constant only `0'e`. Later
NumericLiteralParser skipped 0 and ' as digits and parsed `e+1` as valid
exponent going past the end of the token. Because it didn't mark numeric
literal as having an error, it continued parsing and tried to expandUCNs
with StringRef of length -2.

The fix is not to parse exponent when we reached the end of token.

Discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4588

rdar://problem/36076719

Reviewers: rsmith, t.p.northover

Reviewed By: rsmith

Subscribers: cfe-commits, jkorous-apple

Differential Revision: https://reviews.llvm.org/D41834

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324419 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Lex/LiteralSupport.cpp
test/Lexer/cxx1y_digit_separators.cpp