sdl12-compat: Add null check to SDL_LoadWAV_RW to avoid crashes

From 041cf9a8630da195bb69a552b739f0052d8c2821 Mon Sep 17 00:00:00 2001
From: Manuel Moos <[EMAIL REDACTED]>
Date: Sun, 6 Aug 2023 17:17:43 +0200
Subject: [PATCH] Add null check to SDL_LoadWAV_RW to avoid crashes

Native SDL 1.2 and 2.0 both handle SDL_LoadWAV(null,...), SDL_LoadWAV("",...) and SDL_LoadWAV(nonexistent_file,...)
by returning NULL and setting an error; this check resores that
behavior.

Fixes https://github.com/libsdl-org/sdl12-compat/issues/310
---
 src/SDL12_compat.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index 5b4536a4e..192b9b7fb 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -8454,6 +8454,10 @@ SDL_LoadWAV_RW(SDL12_RWops *rwops12, int freerwops12,
     SDL_RWops *rwops20 = RWops12to20(rwops12);
     SDL_AudioSpec *retval = NULL;
 
+    if (!rwops20) {
+        return NULL;
+    }
+
     *buf = NULL;
 
     /* SDL2's LoadWAV requires a seekable stream, but SDL 1.2 didn't,