Database*: fix nullptr dereference when no database is configured

This commit is contained in:
Max Kellermann
2012-08-22 21:40:20 +02:00
parent af4252bc80
commit e8df7e8da5
5 changed files with 48 additions and 8 deletions

View File

@@ -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)
{