1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 04:17:33 +00:00

fix temporary printing of "(null)" for mpd vars

To minimise the chance of printing variables in an undefined state, call
free() as late as possible (i.e., right before strdup()'ing the new
value).
This commit is contained in:
Phil Sutter 2009-03-23 23:42:59 +01:00
parent 4c77eed1c3
commit 363bed34ac

View File

@ -132,8 +132,6 @@ static void *update_mpd_thread(void *arg)
const char *emptystr = "";
while (1) {
clear_mpd();
if (!conn)
conn = mpd_newConnection(mpd_host, mpd_port, 10);
@ -248,7 +246,13 @@ static void *update_mpd_thread(void *arg)
mpd_freeInfoEntity(entity);
continue;
}
#define SONGSET(x) if(song->x) mpd_info.x = strmdup(song->x); else mpd_info.x = strmdup(emptystr)
#define SONGSET(x) { \
free(mpd_info.x); \
if(song->x) \
mpd_info.x = strmdup(song->x); \
else \
mpd_info.x = strmdup(emptystr); \
}
SONGSET(artist);
SONGSET(album);
SONGSET(title);