aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_thread.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-31 16:47:21 +0100
committerMax Kellermann <max@duempel.org>2008-10-31 16:47:21 +0100
commita5f8d4386c3d7b59bab15499d5d70f8d2713626f (patch)
tree148790958d648b34564a6c4216f3db42614c7d9d /src/decoder_thread.c
parentd8e877e3355d0858c78a6d9a7060a6683024dd30 (diff)
downloadmpd-a5f8d4386c3d7b59bab15499d5d70f8d2713626f.tar.gz
mpd-a5f8d4386c3d7b59bab15499d5d70f8d2713626f.tar.xz
mpd-a5f8d4386c3d7b59bab15499d5d70f8d2713626f.zip
update: check return values
Nearly all mapper functions can fail and will then return NULL. Add checks to all callers.
Diffstat (limited to 'src/decoder_thread.c')
-rw-r--r--src/decoder_thread.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/decoder_thread.c b/src/decoder_thread.c
index 0e9633292..14a1f858f 100644
--- a/src/decoder_thread.c
+++ b/src/decoder_thread.c
@@ -31,20 +31,25 @@
static void decodeStart(void)
{
struct song *song = dc.next_song;
+ char buffer[MPD_PATH_MAX];
+ const char *uri;
struct decoder decoder;
int ret;
bool close_instream = true;
struct input_stream inStream;
struct decoder_plugin *plugin = NULL;
- char path_max_fs[MPD_PATH_MAX];
if (song_is_file(song))
- map_song_fs(song, path_max_fs);
+ uri = map_song_fs(song, buffer);
else
- song_get_url(song, path_max_fs);
+ uri = song_get_url(song, buffer);
+ if (uri == NULL) {
+ dc.error = DECODE_ERROR_FILE;
+ return;
+ }
dc.current_song = dc.next_song; /* NEED LOCK */
- if (!input_stream_open(&inStream, path_max_fs)) {
+ if (!input_stream_open(&inStream, uri)) {
dc.error = DECODE_ERROR_FILE;
return;
}
@@ -98,7 +103,7 @@ static void decodeStart(void)
/* if that fails, try suffix matching the URL: */
if (plugin == NULL) {
- const char *s = getSuffix(path_max_fs);
+ const char *s = getSuffix(uri);
next = 0;
while ((plugin = decoder_plugin_from_suffix(s, next++))) {
if (plugin->stream_decode == NULL)
@@ -129,7 +134,7 @@ static void decodeStart(void)
}
} else {
unsigned int next = 0;
- const char *s = getSuffix(path_max_fs);
+ const char *s = getSuffix(uri);
while ((plugin = decoder_plugin_from_suffix(s, next++))) {
if (!plugin->stream_types & INPUT_PLUGIN_STREAM_FILE)
continue;
@@ -142,8 +147,7 @@ static void decodeStart(void)
input_stream_close(&inStream);
close_instream = false;
decoder.plugin = plugin;
- ret = plugin->file_decode(&decoder,
- path_max_fs);
+ ret = plugin->file_decode(&decoder, uri);
break;
} else if (plugin->stream_decode != NULL) {
decoder.plugin = plugin;