summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorDave Bryant <bryant@rockbox.org>2007-07-27 03:18:45 +0000
committerDave Bryant <bryant@rockbox.org>2007-07-27 03:18:45 +0000
commitee7caed7d95e209361406735805dc66718575ea7 (patch)
treeca343866261e223fb5905dc362cf47ae4bc1b72c /apps/codecs
parent5e8dad8dfa84e76d5cc934020540fbb35c79b21a (diff)
fixes bug that prevented playback of WavPack files containing over 1000 bytes of RIFF header data
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14019 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/libwavpack/metadata.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/apps/codecs/libwavpack/metadata.c b/apps/codecs/libwavpack/metadata.c
index b7d1e950bf..c7f2d61841 100644
--- a/apps/codecs/libwavpack/metadata.c
+++ b/apps/codecs/libwavpack/metadata.c
@@ -16,6 +16,7 @@
int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd)
{
+ uint32_t bytes_to_read;
uchar tchar;
if (!wpc->infile (&wpmd->id, 1) || !wpc->infile (&tchar, 1))
@@ -42,18 +43,29 @@ int read_metadata_buff (WavpackContext *wpc, WavpackMetadata *wpmd)
wpmd->byte_length--;
}
- if (wpmd->byte_length && wpmd->byte_length <= (int32_t)sizeof (wpc->read_buffer)) {
- uint32_t bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1);
+ if (!wpmd->byte_length || wpmd->id == ID_WV_BITSTREAM) {
+ wpmd->data = NULL;
+ return TRUE;
+ }
- if (wpc->infile (wpc->read_buffer, bytes_to_read) != (int32_t) bytes_to_read) {
- wpmd->data = NULL;
- return FALSE;
- }
+ bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1);
- wpmd->data = wpc->read_buffer;
+ if (bytes_to_read > sizeof (wpc->read_buffer)) {
+ wpmd->data = NULL;
+
+ while (bytes_to_read > sizeof (wpc->read_buffer))
+ if (wpc->infile (wpc->read_buffer, sizeof (wpc->read_buffer)) == sizeof (wpc->read_buffer))
+ bytes_to_read -= sizeof (wpc->read_buffer);
+ else
+ return FALSE;
}
else
+ wpmd->data = wpc->read_buffer;
+
+ if (bytes_to_read && wpc->infile (wpc->read_buffer, bytes_to_read) != (int32_t) bytes_to_read) {
wpmd->data = NULL;
+ return FALSE;
+ }
return TRUE;
}