summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2017-10-18 17:25:24 -0700
committerJosh Gao <jmgao@google.com>2017-10-18 17:29:39 -0700
commit44f6e189d97fa3e07e2a95605d4ecd76bc73b103 (patch)
tree7d408fac0b7c362e025aca37b4cbd3bd9bd55490
parentab9dc08bdd60d3709e1bce555625d923b32812be (diff)
Correctly call vector::erase after std::remove_if.
std::remove_if moves removed elements to the end, without actually resizing the collection. To do so, you have to call erase on its returned iterator. Test: mma Change-Id: Iae7f2f194166408f2b101d0c1cfc95202d8bbe63
-rw-r--r--linker/linker_main.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 479973972..46cd60ccb 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -129,9 +129,8 @@ static void parse_LD_PRELOAD(const char* path) {
if (path != nullptr) {
// We have historically supported ':' as well as ' ' in LD_PRELOAD.
g_ld_preload_names = android::base::Split(path, " :");
- std::remove_if(g_ld_preload_names.begin(),
- g_ld_preload_names.end(),
- [] (const std::string& s) { return s.empty(); });
+ g_ld_preload_names.erase(std::remove_if(g_ld_preload_names.begin(), g_ld_preload_names.end(),
+ [](const std::string& s) { return s.empty(); }));
}
}