From 44f6e189d97fa3e07e2a95605d4ecd76bc73b103 Mon Sep 17 00:00:00 2001 From: Josh Gao Date: Wed, 18 Oct 2017 17:25:24 -0700 Subject: 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 --- linker/linker_main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'linker/linker_main.cpp') 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(); })); } } -- cgit v1.2.3