db/update/Walk: fix crash when music_directory is not a directory

Add a runtime sanity check to avoid the assertion failure.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/660
This commit is contained in:
Max Kellermann 2019-10-07 12:23:58 +02:00
parent b9b906ab20
commit 23d08820a2
2 changed files with 8 additions and 0 deletions

2
NEWS
View File

@ -1,4 +1,6 @@
ver 0.21.16 (not yet released) ver 0.21.16 (not yet released)
* update
- fix crash when music_directory is not a directory
ver 0.21.15 (2019/09/25) ver 0.21.15 (2019/09/25)
* decoder * decoder

View File

@ -493,6 +493,12 @@ UpdateWalk::Walk(Directory &root, const char *path, bool discard) noexcept
if (!GetInfo(storage, "", info)) if (!GetInfo(storage, "", info))
return false; return false;
if (!info.IsDirectory()) {
FormatError(update_domain, "Not a directory: %s",
storage.MapUTF8("").c_str());
return false;
}
ExcludeList exclude_list; ExcludeList exclude_list;
UpdateDirectory(root, exclude_list, info); UpdateDirectory(root, exclude_list, info);