1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Dave Bryant 2007-07-27 03:18:45 +00:00
parent 5e8dad8dfa
commit ee7caed7d9

View file

@ -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,19 +43,30 @@ 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) {
bytes_to_read = wpmd->byte_length + (wpmd->byte_length & 1);
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;
}
wpmd->data = wpc->read_buffer;
}
else
wpmd->data = NULL;
return TRUE;
}