From 209364adf2c143d2979f95f748b9aef642bde0d9 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 5 May 2020 18:57:13 +0200 Subject: [PATCH] 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 --- NEWS | 2 ++ src/db/plugins/simple/SimpleDatabasePlugin.cxx | 7 +------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 0836c5ce8..d3e275df3 100644 --- a/NEWS +++ b/NEWS @@ -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) diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index ebb34ee14..5350db6d8 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -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; - } + Mount(local_uri, std::move(db)); } inline DatabasePtr