From 73ac3b8e264df144a14084f633841bb314ae9294 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sun, 4 Dec 2016 14:56:06 +0000 Subject: wallet2: avoid possible undefined behavior on empty string --- src/wallet/wallet2.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/wallet/wallet2.cpp') diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index ea3994435..f637c8b03 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -191,8 +191,7 @@ boost::optional get_password(const boost::program_opt } // Remove line breaks the user might have inserted - password.erase(std::remove(password.end() - 1, password.end(), '\n'), password.end()); - password.erase(std::remove(password.end() - 1, password.end(), '\r'), password.end()); + boost::trim_right_if(password, boost::is_any_of("\r\n")); return {tools::password_container(std::move(password))}; } -- cgit v1.2.3