db/simple: fix crash when mounting twice

The `db->close()` call was a `nullptr` dereference because the `db`
variable had already been moved.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/839
This commit is contained in:
Max Kellermann 2020-05-05 18:57:13 +02:00
parent 24afdee35c
commit 209364adf2
2 changed files with 3 additions and 6 deletions

2
NEWS
View File

@ -1,6 +1,8 @@
ver 0.21.24 (not yet released)
* protocol
- "tagtypes" requires no permissions
* database
- simple: fix crash when mounting twice
* fix unit test failure
ver 0.21.23 (2020/04/23)

View File

@ -449,12 +449,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri)
// TODO: update the new database instance?
try {
Mount(local_uri, std::move(db));
} catch (...) {
db->Close();
throw;
}
}
inline DatabasePtr