[clang-tidy] Fix use-after-free in UseNullptrCheck.

llvm-svn: 245524
This commit is contained in:
Alexander Kornienko 2015-08-19 23:57:34 +00:00
parent dbd22a9a6c
commit 0777b3cffe
2 changed files with 5 additions and 6 deletions

View File

@ -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) {

View File

@ -24,6 +24,7 @@ public:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
private:
const std::string NullMacrosStr;
SmallVector<StringRef, 1> NullMacros;
};