We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2280

Summary: uninitialized wavespec used in SDL_BuildAudioCVT
Product: SDL_mixer Reporter: Nitz <nitin.j4>
Component: miscAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: 1.2.11   
Hardware: x86   
OS: Linux   

Description Nitz 2013-12-02 06:20:00 UTC
In WAVStream *WAVStream_LoadSong_RW(SDL_RWops *src, int freesrc) function

if( magic == RIFF || magic == WAVE ) and if( magic == FORM ) both conditions fails then wavespec remain uninitialized and used in
 
SDL_BuildAudioCVT(&wave->cvt,
                wavespec.format, wavespec.channels, wavespec.freq,
                mixer.format, mixer.channels, mixer.freq);

Which causes undefined behaviour.

patch for this bug:


if ( magic == RIFF || magic == WAVE ) {
             wave->src = LoadWAVStream(src, &wavespec, &wave->start, &wave->stop);
         } else if ( magic == FORM ) {
             wave->src = LoadAIFFStream(src, &wavespec, &wave->start, &wave->stop);
         } else {
             Mix_SetError("Unknown WAVE format");
             SDL_free(wave); // Thses 2 lines should be added.
             return(NULL); //
         }

Cheers....
Comment 1 Sam Lantinga 2019-06-10 16:05:40 UTC
This has been fixed.