Browse Source

[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
Benjamin Kramer 8 years ago
parent
commit
ce2bd42c85
1 changed files with 2 additions and 1 deletions
  1. 2 1
      lib/ASTMatchers/Dynamic/Parser.cpp

+ 2 - 1
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;