SDL: Return the correct error from SDL_CreateSoftwareRenderer() when the surface is NULL

From c057849035d6d985777ed15cfed178ee379ee98c Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 5 Jul 2024 08:05:20 -0700
Subject: [PATCH] Return the correct error from SDL_CreateSoftwareRenderer()
 when the surface is NULL

---
 src/render/SDL_render.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index ed705272df389..f1c72d3c1d813 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1156,6 +1156,11 @@ SDL_Renderer *SDL_CreateSoftwareRenderer(SDL_Surface *surface)
 {
 #if SDL_VIDEO_RENDER_SW
     SDL_Renderer *renderer;
+
+	if (!surface) {
+        SDL_InvalidParamError("surface");
+	}
+
     SDL_PropertiesID props = SDL_CreateProperties();
     SDL_SetProperty(props, SDL_PROP_RENDERER_CREATE_SURFACE_POINTER, surface);
     renderer = SDL_CreateRendererWithProperties(props);