r190984 - Fix use-after-free in r190980.
Eli Friedman
eli.friedman at gmail.com
Wed Sep 18 18:51:23 PDT 2013
Author: efriedma
Date: Wed Sep 18 20:51:23 2013
New Revision: 190984
URL: http://llvm.org/viewvc/llvm-project?rev=190984&view=rev
Log:
Fix use-after-free in r190980.
Modified:
cfe/trunk/lib/Lex/Lexer.cpp
Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=190984&r1=190983&r2=190984&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Sep 18 20:51:23 2013
@@ -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
More information about the cfe-commits
mailing list