[clang-tools-extra] r245524 - [clang-tidy] Fix use-after-free in UseNullptrCheck.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 19 16:57:34 PDT 2015
Author: alexfh
Date: Wed Aug 19 18:57:34 2015
New Revision: 245524
URL: http://llvm.org/viewvc/llvm-project?rev=245524&view=rev
Log:
[clang-tidy] Fix use-after-free in UseNullptrCheck.
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.h
Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp?rev=245524&r1=245523&r2=245524&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp Wed Aug 19 18:57:34 2015
@@ -12,7 +12,6 @@
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"
-#include "llvm/ADT/StringExtras.h"
using namespace clang;
using namespace clang::ast_matchers;
@@ -441,14 +440,13 @@ private:
};
UseNullptrCheck::UseNullptrCheck(StringRef Name, ClangTidyContext *Context)
- : ClangTidyCheck(Name, Context) {
- StringRef MacrosStr = Options.get("NullMacros", "NULL");
- MacrosStr.split(NullMacros, ",");
+ : ClangTidyCheck(Name, Context),
+ NullMacrosStr(Options.get("NullMacros", "NULL")) {
+ StringRef(NullMacrosStr).split(NullMacros, ",");
}
void UseNullptrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
- Options.store(Opts, "NullMacros",
- llvm::join(NullMacros.begin(), NullMacros.end(), ","));
+ Options.store(Opts, "NullMacros", NullMacrosStr);
}
void UseNullptrCheck::registerMatchers(MatchFinder *Finder) {
Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.h?rev=245524&r1=245523&r2=245524&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.h Wed Aug 19 18:57:34 2015
@@ -24,6 +24,7 @@ public:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
+ const std::string NullMacrosStr;
SmallVector<StringRef, 1> NullMacros;
};
More information about the cfe-commits
mailing list