db/proxy: check connect error before initializing SocketMonitor

Fixes crash bug because mpd_connection_get_async() was called without
a connection.
This commit is contained in:
Max Kellermann 2014-03-06 13:35:42 +01:00
parent 9da57e7458
commit f2f1801c25

View File

@ -353,19 +353,19 @@ ProxyDatabase::Connect(Error &error)
return false;
}
if (!CheckError(connection, error)) {
mpd_connection_free(connection);
connection = nullptr;
return false;
}
idle_received = unsigned(-1);
is_idle = false;
SocketMonitor::Open(mpd_async_get_fd(mpd_connection_get_async(connection)));
IdleMonitor::Schedule();
if (!CheckError(connection, error)) {
if (connection != nullptr)
Disconnect();
return false;
}
return true;
}