From ce2bd42c852d229fa07ff64b85d0715cc7a24d33 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 9 Jun 2017 17:55:42 +0000 Subject: [PATCH] [ASTMatchers] Fix use after free. Found by asan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305094 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ASTMatchers/Dynamic/Parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ASTMatchers/Dynamic/Parser.cpp b/lib/ASTMatchers/Dynamic/Parser.cpp index ff5c5fb657..f5bd296689 100644 --- a/lib/ASTMatchers/Dynamic/Parser.cpp +++ b/lib/ASTMatchers/Dynamic/Parser.cpp @@ -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; -- 2.50.1