From ff6b263b48f1f9e00dbd5d41863af6862fd2bdf0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jan 2018 13:46:03 +0100 Subject: [PATCH 1/5] increment version number to 0.20.15 --- NEWS | 2 ++ configure.ac | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 00a841b6a..2dec0eb2e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +ver 0.20.15 (not yet released) + ver 0.20.14 (2018/01/01) * database - simple: fix file corruption in the presence of mount points diff --git a/configure.ac b/configure.ac index d9190dc3a..29ee4cf6d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ AC_PREREQ(2.60) -AC_INIT(mpd, 0.20.14, musicpd-dev-team@lists.sourceforge.net) +AC_INIT(mpd, 0.20.15, musicpd-dev-team@lists.sourceforge.net) VERSION_MAJOR=0 VERSION_MINOR=20 -VERSION_REVISION=14 +VERSION_REVISION=15 VERSION_EXTRA=0 AC_CONFIG_SRCDIR([src/Main.cxx]) From 4db1b1b25051f6399f5be477b1bed9644b8c2b71 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jan 2018 13:48:16 +0100 Subject: [PATCH 2/5] storage/State: remove useless #ifdef ENABLE_DATABASE This source file isn't compiled when the database is disabled. --- src/storage/StorageState.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/storage/StorageState.cxx b/src/storage/StorageState.cxx index 721a0ce37..2e5530738 100644 --- a/src/storage/StorageState.cxx +++ b/src/storage/StorageState.cxx @@ -99,7 +99,6 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) return true; } -#ifdef ENABLE_DATABASE Database *db = instance.database; if (db != nullptr && db->IsPlugin(simple_db_plugin)) { try { @@ -108,7 +107,6 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) throw; } } -#endif ((CompositeStorage*)instance.storage)->Mount(uri.c_str(), storage); From a20b3268079149c925189a7e51db3f79f5153f5a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jan 2018 14:05:07 +0100 Subject: [PATCH 3/5] storage/State: fix memory leak after database mount failure Caused by commit 64d141f71e690a4258ba9ee8712140bc9d961883 This wasn't a serious memory leak, because after a mount failure, MPD would abort anyway, which is subject to the next commit. --- src/storage/StorageState.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/storage/StorageState.cxx b/src/storage/StorageState.cxx index 2e5530738..7c7d49295 100644 --- a/src/storage/StorageState.cxx +++ b/src/storage/StorageState.cxx @@ -104,6 +104,7 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) try { ((SimpleDatabase *)db)->Mount(uri.c_str(), url.c_str()); } catch (...) { + delete storage; throw; } } From 08db28469df91a4e6b916772dfed1aa036b57d38 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jan 2018 14:07:23 +0100 Subject: [PATCH 4/5] storage/State: make mount errors non-fatal Fixes crash bug caused by commit 64d141f71e690a4258ba9ee8712140bc9d961883 --- src/storage/StorageState.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/storage/StorageState.cxx b/src/storage/StorageState.cxx index 7c7d49295..f6d93c2f0 100644 --- a/src/storage/StorageState.cxx +++ b/src/storage/StorageState.cxx @@ -105,7 +105,10 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) ((SimpleDatabase *)db)->Mount(uri.c_str(), url.c_str()); } catch (...) { delete storage; - throw; + FormatError(std::current_exception(), + "Failed to restore mount to %s", + url.c_str()); + return true; } } From ff624075a827870bbd05b858d83fd82f4a31a0a4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 2 Jan 2018 14:13:26 +0100 Subject: [PATCH 5/5] storage/State: check if a CompositeStorage exists; fixes nullptr dereference Fixes another crash bug caused by commit 64d141f71e690a4258ba9ee8712140bc9d961883 --- NEWS | 3 +++ src/storage/StorageState.cxx | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/NEWS b/NEWS index 2dec0eb2e..7107eeb31 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,7 @@ ver 0.20.15 (not yet released) +* state file + - make mount point restore errors non-fatal + - fix crash when restoring mounts with incompatible database plugin ver 0.20.14 (2018/01/01) * database diff --git a/src/storage/StorageState.cxx b/src/storage/StorageState.cxx index f6d93c2f0..1eedda89f 100644 --- a/src/storage/StorageState.cxx +++ b/src/storage/StorageState.cxx @@ -48,6 +48,9 @@ static constexpr Domain storage_domain("storage"); void storage_state_save(BufferedOutputStream &os, const Instance &instance) { + if (instance.storage == nullptr) + return; + const auto visitor = [&os](const char *mount_uri, const Storage &storage) { std::string uri = storage.MapUTF8(""); if (uri.empty() || StringIsEmpty(mount_uri)) @@ -85,6 +88,12 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) FormatError(storage_domain, "Unrecognized line in mountpoint state: %s", line); } + if (instance.storage == nullptr) + /* without storage (a CompositeStorage instance), we + cannot mount, and therefore we silently ignore the + state file */ + return true; + if (url.empty() || uri.empty()) { LogError(storage_domain, "Missing value in mountpoint state."); return true; @@ -120,6 +129,9 @@ storage_state_restore(const char *line, TextFile &file, Instance &instance) unsigned storage_state_get_hash(const Instance &instance) { + if (instance.storage == nullptr) + return 0; + std::set mounts; const auto visitor = [&mounts](const char *mount_uri, const Storage &storage) {