summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Pennequin <nicolas.pennequin@free.fr>2008-04-16 16:41:35 +0000
committerNicolas Pennequin <nicolas.pennequin@free.fr>2008-04-16 16:41:35 +0000
commit2cf6345a0eea4f5fb87723799bf0c20a550bdfd8 (patch)
tree33d38114629b2f565e98b5ef5164684521ddc707
parentde026dcedefec81b585a7e00a06712273d57ea64 (diff)
downloadrockbox-2cf6345a0eea4f5fb87723799bf0c20a550bdfd8.tar.gz
rockbox-2cf6345a0eea4f5fb87723799bf0c20a550bdfd8.tar.bz2
rockbox-2cf6345a0eea4f5fb87723799bf0c20a550bdfd8.zip
bufgetid3 should be used carefully, as it can return NULL.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17143 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playback.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 922a30d2be..222af769b1 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -1519,13 +1519,17 @@ static bool audio_loadcodec(bool start_play)
{
int prev_track;
char codec_path[MAX_PATH]; /* Full path to codec */
+ const struct mp3entry *id3, *prev_id3;
if (tracks[track_widx].id3_hid < 0) {
return false;
}
- const char * codec_fn =
- get_codec_filename(bufgetid3(tracks[track_widx].id3_hid)->codectype);
+ id3 = bufgetid3(tracks[track_widx].id3_hid);
+ if (!id3)
+ return false;
+
+ const char *codec_fn = get_codec_filename(id3->codectype);
if (codec_fn == NULL)
return false;
@@ -1550,12 +1554,14 @@ static bool audio_loadcodec(bool start_play)
{
prev_track = (track_widx - 1) & MAX_TRACK_MASK;
+ id3 = bufgetid3(tracks[track_widx].id3_hid);
+ prev_id3 = bufgetid3(tracks[prev_track].id3_hid);
+
/* If the previous codec is the same as this one, there is no need
* to put another copy of it on the file buffer */
- if (get_codec_base_type(
- bufgetid3(tracks[track_widx].id3_hid)->codectype) ==
- get_codec_base_type(
- bufgetid3(tracks[prev_track].id3_hid)->codectype)
+ if (id3 && prev_id3 &&
+ get_codec_base_type(id3->codectype) ==
+ get_codec_base_type(prev_id3->codectype)
&& audio_codec_loaded)
{
logf("Reusing prev. codec");