PlaylistFile: fix memory leak

Consistently use std::string in LoadPlaylistFile().
This commit is contained in:
Max Kellermann 2013-10-14 21:53:08 +02:00
parent 9067da2df8
commit c96b295700
1 changed files with 10 additions and 12 deletions

View File

@ -241,27 +241,25 @@ LoadPlaylistFile(const char *utf8path, Error &error)
if (*s == 0 || *s == PLAYLIST_COMMENT) if (*s == 0 || *s == PLAYLIST_COMMENT)
continue; continue;
std::string uri_utf8;
if (g_path_is_absolute(s)) { if (g_path_is_absolute(s)) {
const auto path = Path::ToUTF8(s); uri_utf8 = Path::ToUTF8(s);
if (path.empty()) if (uri_utf8.empty())
continue; continue;
s = g_strconcat("file://", path.c_str(), NULL); uri_utf8.insert(0, "file://");
} else if (!uri_has_scheme(s)) { } else if (!uri_has_scheme(s)) {
const auto path = map_fs_to_utf8(s); uri_utf8 = map_fs_to_utf8(s);
if (path.empty()) if (uri_utf8.empty())
continue; continue;
s = g_strdup(path.c_str());
} else { } else {
const auto path = Path::ToUTF8(s); uri_utf8 = Path::ToUTF8(s);
if (path.empty()) if (uri_utf8.empty())
continue; continue;
s = g_strdup(path.c_str());
} }
contents.emplace_back(s); contents.emplace_back(std::move(uri_utf8));
if (contents.size() >= playlist_max_length) if (contents.size() >= playlist_max_length)
break; break;
} }