aboutsummaryrefslogtreecommitdiffstats
path: root/src/DatabaseGlue.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-08-22 21:40:20 +0200
committerMax Kellermann <max@duempel.org>2012-08-22 21:40:20 +0200
commite8df7e8da5a075178224b130c0602b62c85508a9 (patch)
tree76d57e65c2094d98909ff2ada88abc717e5422f9 /src/DatabaseGlue.cxx
parentaf4252bc8043487a47a42a07326caf44bc78714f (diff)
downloadmpd-e8df7e8da5a075178224b130c0602b62c85508a9.tar.gz
mpd-e8df7e8da5a075178224b130c0602b62c85508a9.tar.xz
mpd-e8df7e8da5a075178224b130c0602b62c85508a9.zip
Database*: fix nullptr dereference when no database is configured
Diffstat (limited to '')
-rw-r--r--src/DatabaseGlue.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx
index 88b25d868..b980ded83 100644
--- a/src/DatabaseGlue.cxx
+++ b/src/DatabaseGlue.cxx
@@ -87,6 +87,18 @@ GetDatabase()
return db;
}
+const Database *
+GetDatabase(GError **error_r)
+{
+ assert(db == nullptr || db_is_open);
+
+ if (db == nullptr)
+ g_set_error_literal(error_r, db_quark(), DB_DISABLED,
+ "No database");
+
+ return db;
+}
+
bool
db_is_simple(void)
{