From c96b29570042eff627d5e956f5ce58630385d18f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 14 Oct 2013 21:53:08 +0200 Subject: PlaylistFile: fix memory leak Consistently use std::string in LoadPlaylistFile(). --- src/PlaylistFile.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/PlaylistFile.cxx') diff --git a/src/PlaylistFile.cxx b/src/PlaylistFile.cxx index b7ed10dfa..7b81d7354 100644 --- a/src/PlaylistFile.cxx +++ b/src/PlaylistFile.cxx @@ -241,27 +241,25 @@ LoadPlaylistFile(const char *utf8path, Error &error) if (*s == 0 || *s == PLAYLIST_COMMENT) continue; + std::string uri_utf8; + if (g_path_is_absolute(s)) { - const auto path = Path::ToUTF8(s); - if (path.empty()) + uri_utf8 = Path::ToUTF8(s); + if (uri_utf8.empty()) continue; - s = g_strconcat("file://", path.c_str(), NULL); + uri_utf8.insert(0, "file://"); } else if (!uri_has_scheme(s)) { - const auto path = map_fs_to_utf8(s); - if (path.empty()) + uri_utf8 = map_fs_to_utf8(s); + if (uri_utf8.empty()) continue; - - s = g_strdup(path.c_str()); } else { - const auto path = Path::ToUTF8(s); - if (path.empty()) + uri_utf8 = Path::ToUTF8(s); + if (uri_utf8.empty()) continue; - - s = g_strdup(path.c_str()); } - contents.emplace_back(s); + contents.emplace_back(std::move(uri_utf8)); if (contents.size() >= playlist_max_length) break; } -- cgit v1.2.3