aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/modplug_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-24 19:16:07 +0100
committerMax Kellermann <max@duempel.org>2009-01-24 19:16:07 +0100
commit0c71640528c5c566ec4770143c7831ace28b51d1 (patch)
tree802f7a6532242e6cc9c172e548f03507e64cd1a4 /src/decoder/modplug_plugin.c
parent961d1722001e4d89a60d5ffd5f553807f0e6f4e9 (diff)
downloadmpd-0c71640528c5c566ec4770143c7831ace28b51d1.tar.gz
mpd-0c71640528c5c566ec4770143c7831ace28b51d1.tar.xz
mpd-0c71640528c5c566ec4770143c7831ace28b51d1.zip
modplug: unknown size is -1; check for empty file
The input_stream API sets size to -1 when the size of the resource is not known. The modplug decoder checked for size==0, which would be an empty file.
Diffstat (limited to 'src/decoder/modplug_plugin.c')
-rw-r--r--src/decoder/modplug_plugin.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/decoder/modplug_plugin.c b/src/decoder/modplug_plugin.c
index 806f070ec..5113d8a2e 100644
--- a/src/decoder/modplug_plugin.c
+++ b/src/decoder/modplug_plugin.c
@@ -38,16 +38,23 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is
int total_len;
int ret;
+ if (is->size == 0) {
+ g_warning("file is empty");
+ return NULL;
+ }
+
+ if (is->size > MODPLUG_FILE_LIMIT) {
+ g_warning("file too large");
+ return NULL;
+ }
+
//known/unknown size, preallocate array, lets read in chunks
- if (is->size) {
- if (is->size > MODPLUG_FILE_LIMIT) {
- g_warning("file too large\n");
- return NULL;
- }
+ if (is->size > 0) {
bdatas = g_byte_array_sized_new(is->size);
} else {
bdatas = g_byte_array_sized_new(MODPLUG_PREALLOC_BLOCK);
}
+
data = g_malloc(MODPLUG_READ_BLOCK);
total_len = 0;
do {