From ff62b6742ba989dd06faa135650371900b327e93 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 17 Feb 2014 22:13:39 +0100 Subject: Main: check if database exists before attempting to close it Fixes nullptr dereference. --- src/Main.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Main.cxx') diff --git a/src/Main.cxx b/src/Main.cxx index 267979f31..ef5f46ee8 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -595,8 +595,11 @@ int mpd_main(int argc, char *argv[]) #ifdef ENABLE_DATABASE delete instance->update; - instance->database->Close(); - delete instance->database; + + if (instance->database != nullptr) { + instance->database->Close(); + delete instance->database; + } #endif #ifdef ENABLE_SQLITE -- cgit v1.2.3