1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-09-29 13:39:10 +00:00

Quick fix for crashes when mpd stops

This commit is contained in:
troxor 2013-04-27 23:29:20 -05:00
parent f0d0a03b8e
commit 38f05de4ca
2 changed files with 9 additions and 7 deletions

View File

@ -484,10 +484,12 @@ void mpd_clearError(mpd_Connection *connection)
void mpd_closeConnection(mpd_Connection *connection)
{
if (connection) {
closesocket(connection->sock);
free_and_zero(connection->returnElement);
free_and_zero(connection->request);
free(connection);
}
WSACleanup();
}
@ -699,7 +701,7 @@ static void mpd_getNextReturnElement(mpd_Connection *connection)
void mpd_finishCommand(mpd_Connection *connection)
{
while (!connection->doneProcessing) {
while (connection && !connection->doneProcessing) {
if (connection->doneListOk) {
connection->doneListOk = 0;
}

View File

@ -192,7 +192,7 @@ namespace {
mpd_info.status = "MPD not responding";
}
mpd_finishCommand(conn);
if (conn->error) {
if (!conn || conn->error) {
// fprintf(stderr, "%s\n", conn->errorStr);
mpd_closeConnection(conn);
conn = 0;
@ -277,7 +277,7 @@ if (b) a=b; else a="";
}
}
mpd_finishCommand(conn);
if (conn->error) {
if (conn && conn->error) {
// fprintf(stderr, "%s\n", conn->errorStr);
mpd_closeConnection(conn);
conn = 0;