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:
parent
4c77eed1c3
commit
363bed34ac
10
src/mpd.c
10
src/mpd.c
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user