]> granicus.if.org Git - clang/commitdiff
fix a potential buffer overrun that Eli noticed
authorChris Lattner <sabre@nondot.org>
Tue, 30 Sep 2008 20:51:14 +0000 (20:51 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 30 Sep 2008 20:51:14 +0000 (20:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56879 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp

index 07428fdac7b9a3e2696978bae2a76384159bd73a..61257187f52544a365639a5f5ae972436f9b3978 100644 (file)
@@ -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)