storage/curl: fix nullptr dereference

Pass a std::string to PathTraitsUTF8::Relative(), implicitly casting
it to std::string_view.  This selects the right overload which returns
std::string_view instead of `const char *`; the latter could return
`nullptr` which would cause the implicit conversion of the return
value to std::string_view to crash.

Regression caused by commits ead208987d and a98d627c0b.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/995
This commit is contained in:
Max Kellermann
2020-11-06 15:33:46 +01:00
parent 2da3cff1e8
commit f849b07766
2 changed files with 3 additions and 1 deletions

View File

@@ -80,7 +80,7 @@ std::string_view
CurlStorage::MapToRelativeUTF8(std::string_view uri_utf8) const noexcept
{
return PathTraitsUTF8::Relative(base,
CurlUnescape(uri_utf8).c_str());
CurlUnescape(uri_utf8));
}
class BlockingHttpRequest : protected CurlResponseHandler {