Mercurial > SDL_sound_CoreAudio
diff decoders/wav.c @ 364:4bcbc442d145
Fix to handle strange WAV fmt chunks.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 13 Jun 2002 23:15:37 +0000 |
parents | 069ce624d6cf |
children | cbb15ecf423a |
line wrap: on
line diff
--- a/decoders/wav.c Thu Jun 13 23:15:15 2002 +0000 +++ b/decoders/wav.c Thu Jun 13 23:15:37 2002 +0000 @@ -142,6 +142,8 @@ Uint16 wBlockAlign; Uint16 wBitsPerSample; + Uint32 next_chunk_offset; + Uint32 sample_frame_size; Uint32 data_starting_offset; Uint32 total_bytes; @@ -182,6 +184,9 @@ fmt->chunkID = fmtID; BAIL_IF_MACRO(!read_le32(rw, &fmt->chunkSize), NULL, 0); + BAIL_IF_MACRO(fmt->chunkSize < 16, "WAV: Invalid chunk size", 0); + fmt->next_chunk_offset = SDL_RWtell(rw) + fmt->chunkSize; + BAIL_IF_MACRO(!read_le16(rw, &fmt->wFormatTag), NULL, 0); BAIL_IF_MACRO(!read_le16(rw, &fmt->wChannels), NULL, 0); BAIL_IF_MACRO(!read_le32(rw, &fmt->dwSamplesPerSec), NULL, 0); @@ -708,6 +713,7 @@ } /* else */ BAIL_IF_MACRO(!read_fmt(rw, fmt), NULL, 0); + SDL_RWseek(rw, fmt->next_chunk_offset, SEEK_SET); BAIL_IF_MACRO(!find_chunk(rw, dataID), "WAV: No data chunk.", 0); BAIL_IF_MACRO(!read_data_chunk(rw, &d), "WAV: Can't read data chunk.", 0);