medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 40475d5e75ca5d7130b370c1d048ca877b7ca22f
parent c0a9502070252a3311e7da6389f15cc86f7f59fc
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Nov  5 21:37:49 +0200

wave_decode robustness

Diffstat:
wave.cc | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/wave.cc b/wave.cc @@ -60,6 +60,8 @@ bool wave_decode( MemoryArena * arena, u8 * data, SoundData * sound ) { u32 pos = sizeof( WaveHeader ); u32 data_length = 0; + sound->samples = NULL; + while( pos < header->length ) { WaveChunk * chunk = ( WaveChunk * ) ( data + pos ); @@ -89,6 +91,8 @@ bool wave_decode( MemoryArena * arena, u8 * data, SoundData * sound ) { pos += sizeof( WaveChunk ) + align2( chunk->length ); } + if( sound->samples == NULL ) return false; + sound->num_samples = data_length / ( sound->num_channels * sizeof( s16 ) ); // uninterleave the samples