diff options
author | Max Kellermann <max@musicpd.org> | 2018-01-02 14:13:26 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-01-02 14:13:26 +0100 |
commit | ff624075a827870bbd05b858d83fd82f4a31a0a4 (patch) | |
tree | d3f56b65829c115c79ebdce57c50b3ee71d5d750 /src | |
parent | 08db28469df91a4e6b916772dfed1aa036b57d38 (diff) |
storage/State: check if a CompositeStorage exists; fixes nullptr dereference
Fixes another crash bug caused by commit
64d141f71e690a4258ba9ee8712140bc9d961883
Diffstat (limited to 'src')
-rw-r--r-- | src/storage/StorageState.cxx | 12 |
1 files changed, 12 insertions, 0 deletions
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<std::string> mounts; const auto visitor = [&mounts](const char *mount_uri, const Storage &storage) { |