]> granicus.if.org Git - clang/commitdiff
Fix use-after-free in r190980.
authorEli Friedman <eli.friedman@gmail.com>
Thu, 19 Sep 2013 01:51:23 +0000 (01:51 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 19 Sep 2013 01:51:23 +0000 (01:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190984 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Lexer.cpp

index 2570755cbdefbb5e6d6c04c3d99068bc84a3b023..e6b6b1fe1c1c49f087e269a91913fd504e1af168 100644 (file)
@@ -2823,9 +2823,12 @@ bool Lexer::Lex(Token &Result) {
 
   bool atPhysicalStartOfLine = IsAtPhysicalStartOfLine;
   IsAtPhysicalStartOfLine = false;
-  bool result = LexTokenInternal(Result, atPhysicalStartOfLine);
-  assert((result || !isLexingRawMode()) && "Raw lex must succeed");
-  return result;
+  bool isRawLex = isLexingRawMode();
+  (void) isRawLex;
+  bool returnedToken = LexTokenInternal(Result, atPhysicalStartOfLine);
+  // (After the LexTokenInternal call, the lexer might be destroyed.)
+  assert((returnedToken || !isRawLex) && "Raw lex must succeed");
+  return returnedToken;
 }
 
 /// LexTokenInternal - This implements a simple C family lexer.  It is an