r305094 - [ASTMatchers] Fix use after free.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 9 10:55:42 PDT 2017
Author: d0k
Date: Fri Jun 9 12:55:42 2017
New Revision: 305094
URL: http://llvm.org/viewvc/llvm-project?rev=305094&view=rev
Log:
[ASTMatchers] Fix use after free.
Found by asan.
Modified:
cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp?rev=305094&r1=305093&r2=305094&view=diff
==============================================================================
--- cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Parser.cpp Fri Jun 9 12:55:42 2017
@@ -206,7 +206,8 @@ private:
if (isFloatingLiteral) {
char *end;
errno = 0;
- double doubleValue = strtod(Result->Text.str().c_str(), &end);
+ std::string Text = Result->Text.str();
+ double doubleValue = strtod(Text.c_str(), &end);
if (*end == 0 && errno == 0) {
Result->Kind = TokenInfo::TK_Literal;
Result->Value = doubleValue;
More information about the cfe-commits
mailing list