diff --git a/src/lib/upnp/Util.cxx b/src/lib/upnp/Util.cxx
index b6cd4189e..e88932b55 100644
--- a/src/lib/upnp/Util.cxx
+++ b/src/lib/upnp/Util.cxx
@@ -30,11 +30,11 @@ trimstring(std::string &s, const char *ws) noexcept
 		s.clear();
 		return;
 	}
-	s.replace(0, pos, std::string());
+	s.erase(0, pos);
 
 	pos = s.find_last_not_of(ws);
 	if (pos != std::string::npos && pos != s.length()-1)
-		s.replace(pos + 1, std::string::npos, std::string());
+		s.erase(pos + 1);
 }
 
 static void