player_control: check if errored_song is set
getPlayerErrorStr() assumes that pc.errored_song is set when an error occured. Since the song may have been deleted meanwhile, add a NULL check.
This commit is contained in:
parent
13192546a8
commit
5d56b6ced8
@ -148,12 +148,22 @@ enum player_error getPlayerError(void)
|
|||||||
return pc.error;
|
return pc.error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
pc_errored_song_uri(void)
|
||||||
|
{
|
||||||
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
|
|
||||||
|
if (pc.errored_song == NULL)
|
||||||
|
return "?";
|
||||||
|
|
||||||
|
return song_get_url(pc.errored_song, path_max_tmp);
|
||||||
|
}
|
||||||
|
|
||||||
char *getPlayerErrorStr(void)
|
char *getPlayerErrorStr(void)
|
||||||
{
|
{
|
||||||
/* static OK here, only one user in main task */
|
/* static OK here, only one user in main task */
|
||||||
static char error[MPD_PATH_MAX + 64]; /* still too much */
|
static char error[MPD_PATH_MAX + 64]; /* still too much */
|
||||||
static const size_t errorlen = sizeof(error);
|
static const size_t errorlen = sizeof(error);
|
||||||
char path_max_tmp[MPD_PATH_MAX];
|
|
||||||
*error = '\0'; /* likely */
|
*error = '\0'; /* likely */
|
||||||
|
|
||||||
switch (pc.error) {
|
switch (pc.error) {
|
||||||
@ -163,11 +173,11 @@ char *getPlayerErrorStr(void)
|
|||||||
case PLAYER_ERROR_FILENOTFOUND:
|
case PLAYER_ERROR_FILENOTFOUND:
|
||||||
snprintf(error, errorlen,
|
snprintf(error, errorlen,
|
||||||
"file \"%s\" does not exist or is inaccessible",
|
"file \"%s\" does not exist or is inaccessible",
|
||||||
song_get_url(pc.errored_song, path_max_tmp));
|
pc_errored_song_uri());
|
||||||
break;
|
break;
|
||||||
case PLAYER_ERROR_FILE:
|
case PLAYER_ERROR_FILE:
|
||||||
snprintf(error, errorlen, "problems decoding \"%s\"",
|
snprintf(error, errorlen, "problems decoding \"%s\"",
|
||||||
song_get_url(pc.errored_song, path_max_tmp));
|
pc_errored_song_uri());
|
||||||
break;
|
break;
|
||||||
case PLAYER_ERROR_AUDIO:
|
case PLAYER_ERROR_AUDIO:
|
||||||
strcpy(error, "problems opening audio device");
|
strcpy(error, "problems opening audio device");
|
||||||
@ -177,7 +187,7 @@ char *getPlayerErrorStr(void)
|
|||||||
break;
|
break;
|
||||||
case PLAYER_ERROR_UNKTYPE:
|
case PLAYER_ERROR_UNKTYPE:
|
||||||
snprintf(error, errorlen, "file type of \"%s\" is unknown",
|
snprintf(error, errorlen, "file type of \"%s\" is unknown",
|
||||||
song_get_url(pc.errored_song, path_max_tmp));
|
pc_errored_song_uri());
|
||||||
}
|
}
|
||||||
return *error ? error : NULL;
|
return *error ? error : NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user