Fixed 1418 - crash on double free if loading WAV file failed SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Sun, 12 Feb 2012 17:58:22 -0500
branchSDL-1.2
changeset 584ea53a85853dd
parent 575 b74a3192c37f
child 585 f2943eac3fd7
Fixed 1418 - crash on double free if loading WAV file failed
mixer.c
     1.1 --- a/mixer.c	Sat Jan 28 10:42:42 2012 -0500
     1.2 +++ b/mixer.c	Sun Feb 12 17:58:22 2012 -0500
     1.3 @@ -610,13 +610,15 @@
     1.4  			break;
     1.5  		default:
     1.6  			SDL_SetError("Unrecognized sound file type");
     1.7 -			return(0);			
     1.8 +			if ( freesrc ) {
     1.9 +				SDL_RWclose(src);
    1.10 +			}
    1.11 +			loaded = NULL;
    1.12 +			break;
    1.13  	}
    1.14  	if ( !loaded ) {
    1.15 +		/* The individual loaders have closed src if needed */
    1.16  		SDL_free(chunk);
    1.17 -		if ( freesrc ) {
    1.18 -			SDL_RWclose(src);
    1.19 -		}
    1.20  		return(NULL);
    1.21  	}
    1.22