From: Chris Lattner Date: Tue, 30 Sep 2008 20:51:14 +0000 (+0000) Subject: fix a potential buffer overrun that Eli noticed X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=28997ec3a493134a8642891944800ffc1c160bee;p=clang fix a potential buffer overrun that Eli noticed git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56879 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 07428fdac7..61257187f5 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -523,6 +523,13 @@ Action::ExprResult Sema::ActOnNumericConstant(const Token &Tok) { // Get the spelling of the token, which eliminates trigraphs, etc. unsigned ActualLength = PP.getSpelling(Tok, ThisTokBegin); + + // Add padding so that NumericLiteralParser can overread by one character. + if (!IntegerBuffer.empty()) { + IntegerBuffer.push_back(' '); + ThisTokBegin = &IntegerBuffer[0]; + } + NumericLiteralParser Literal(ThisTokBegin, ThisTokBegin+ActualLength, Tok.getLocation(), PP); if (Literal.hadError)