diff options
author | Dan Willemsen <dan@danw.org> | 2016-09-20 13:26:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-20 13:26:34 -0700 |
commit | 5e45e973c38c92c42cc86aa5dafeca13e6823b5f (patch) | |
tree | a762d85e42d042acf8682366a2f9741fa1eb92b9 | |
parent | 2ef045a0dcc3a3214cf770695722fb09682dfda8 (diff) | |
parent | 5131f84ef22b6696f1c16f94d4d4fb332c3b6398 (diff) | |
download | android_build_kati-5e45e973c38c92c42cc86aa5dafeca13e6823b5f.tar.gz android_build_kati-5e45e973c38c92c42cc86aa5dafeca13e6823b5f.tar.bz2 android_build_kati-5e45e973c38c92c42cc86aa5dafeca13e6823b5f.zip |
Merge pull request #92 from danw/asan_workaround
Workaround lifetime problem identified by ASAN
-rw-r--r-- | find.cc | 16 | ||||
-rw-r--r-- | find.h | 2 |
2 files changed, 9 insertions, 9 deletions
@@ -585,7 +585,7 @@ class FindCommandParser { } else if (tok.find_first_of("|;&><*'\"") != string::npos) { return false; } else { - fc_->finddirs.push_back(tok); + fc_->finddirs.push_back(tok.as_string()); } } } @@ -594,7 +594,7 @@ class FindCommandParser { fc_->type = FindCommandType::FINDLEAVES; fc_->follows_symlinks = true; StringPiece tok; - vector<StringPiece> findfiles; + vector<string> findfiles; while (true) { if (!GetNextToken(&tok)) return false; @@ -604,13 +604,13 @@ class FindCommandParser { if (findfiles.size() < 2) return false; fc_->finddirs.swap(findfiles); - fc_->print_cond.reset(new NameCond(fc_->finddirs.back().as_string())); + fc_->print_cond.reset(new NameCond(fc_->finddirs.back())); fc_->finddirs.pop_back(); } else { if (findfiles.size() < 1) return false; for (auto& file : findfiles) { - FindCond* cond = new NameCond(file.as_string()); + FindCond* cond = new NameCond(file); if (fc_->print_cond.get()) { cond = new OrCond(fc_->print_cond.release(), cond); } @@ -640,12 +640,12 @@ class FindCommandParser { fc_->mindepth = d; } else if (HasPrefix(tok, "--dir=")) { StringPiece dir= tok.substr(strlen("--dir=")); - fc_->finddirs.push_back(dir); + fc_->finddirs.push_back(dir.as_string()); } else if (HasPrefix(tok, "--")) { WARN("Unknown flag in findleaves.py: %.*s", SPF(tok)); return false; } else { - findfiles.push_back(tok); + findfiles.push_back(tok.as_string()); } } } @@ -788,7 +788,7 @@ class FindEmulatorImpl : public FindEmulator { } const size_t orig_out_size = out->size(); - for (StringPiece finddir : fc.finddirs) { + for (const string& finddir : fc.finddirs) { const string dir = ConcatDir(fc.chdir, finddir); if (!CanHandle(dir)) { @@ -813,7 +813,7 @@ class FindEmulatorImpl : public FindEmulator { continue; } - string path = finddir.as_string(); + string path = finddir; unordered_map<const DirentNode*, string> cur_read_dirs; if (!base->RunFind(fc, 0, &path, &cur_read_dirs, out)) { LOG("FindEmulator: RunFind failed: %s", cmd.c_str()); @@ -41,7 +41,7 @@ struct FindCommand { FindCommandType type; string chdir; string testdir; - vector<StringPiece> finddirs; + vector<string> finddirs; bool follows_symlinks; unique_ptr<FindCond> print_cond; unique_ptr<FindCond> prune_cond; |