SDL_mixer: flip the wavfree condition in previous patch, better document the issue.

From 615882306946a840a9725eb74e8c247dc43f9518 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 8 Oct 2022 01:11:40 +0300
Subject: [PATCH] flip the wavfree condition in previous patch, better document
 the issue.

---
 CHANGES |  4 +++-
 mixer.c | 12 ++++++------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/CHANGES b/CHANGES
index 40e40950..4cfba293 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
 1.2.13:
-- Mix_LoadWAV_RW: Fixed an incompatibility with sdl12-compat.
+- Mix_LoadWAV_RW, Mix_FreeChunk: Fixed a free() function / C library
+  incompatibility with SDL side, fixing crashes against sdl12-compat
+  in particular.
 - MP3: Added playback support using libmpg123 and removed deprecated
   smpeg support.
 - MP3, mad decoder: skip tags, which otherwise would lead to crashes
diff --git a/mixer.c b/mixer.c
index 317f482c..eac23ea1 100644
--- a/mixer.c
+++ b/mixer.c
@@ -646,8 +646,8 @@ Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
 		if ( SDL_BuildAudioCVT(&wavecvt,
 				wavespec.format, wavespec.channels, wavespec.freq,
 				mixer.format, mixer.channels, mixer.freq) < 0 ) {
-			if (!wavfree)SDL_free(chunk->abuf);
-			else	SDL_FreeWAV(chunk->abuf);
+			if (wavfree) SDL_FreeWAV(chunk->abuf);
+			else	SDL_free(chunk->abuf);
 			SDL_free(chunk);
 			return(NULL);
 		}
@@ -656,14 +656,14 @@ Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
 		wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult);
 		if ( wavecvt.buf == NULL ) {
 			SDL_SetError("Out of memory");
-			if (!wavfree) SDL_free(chunk->abuf);
-			else	SDL_FreeWAV(chunk->abuf);
+			if (wavfree) SDL_FreeWAV(chunk->abuf);
+			else	SDL_free(chunk->abuf);
 			SDL_free(chunk);
 			return(NULL);
 		}
 		memcpy(wavecvt.buf, chunk->abuf, wavecvt.len);
-		if (!wavfree) SDL_free(chunk->abuf);
-		else	SDL_FreeWAV(chunk->abuf);
+		if (wavfree) SDL_FreeWAV(chunk->abuf);
+		else	SDL_free(chunk->abuf);
 
 		/* Run the audio converter */
 		if ( SDL_ConvertAudio(&wavecvt) < 0 ) {