1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-15 17:47:09 +00:00

Merge pull request #10 from troxor/fixmpdcrash

Quick fix for crashes when mpd stops
This commit is contained in:
Brenden Matthews 2013-05-23 17:19:30 -07:00
commit c5c0294785
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)
{
closesocket(connection->sock);
free_and_zero(connection->returnElement);
free_and_zero(connection->request);
free(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;