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
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 4799739..46cd60c 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -129,9 +129,8 @@
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(); }));
}
}