sdl12-compat: video: Deal with dest alpha save/restore of full (NULL) dstrect.

From a3611abb7a98d14c0e5d61eea1d7818e719f2335 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Mon, 3 Oct 2022 20:53:47 -0400
Subject: [PATCH] video: Deal with dest alpha save/restore of full (NULL)
 dstrect.

Reference Issue #230.
---
 src/SDL12_compat.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index db151fe1..4c545b63 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -6162,15 +6162,23 @@ SaveDestAlpha(SDL12_Surface *src12, SDL12_Surface *dst12, const SDL12_Rect *dstr
     const SDL_bool save_dstalpha = ((src12->flags & SDL12_SRCALPHA) && dst12->format->Amask && ((src12->format->alpha != 255) || src12->format->Amask)) ? SDL_TRUE : SDL_FALSE;
 
     if (save_dstalpha) {
-        Uint8 *dptr;
-        int x, y;
-
-        const int w = dstrect12->w;
-        const int h = dstrect12->h;
-
         const Uint32 amask = dst12->format->Amask;
         const Uint32 ashift = dst12->format->Ashift;
         const Uint16 pitch = dst12->pitch;
+        SDL12_Rect fullrect;
+        Uint8 *dptr;
+        int x, y, w, h;
+
+        if (!dstrect12) {
+            fullrect.x = 0;
+            fullrect.y = 0;
+            fullrect.w = dst12->w;
+            fullrect.h = dst12->h;
+            dstrect12 = &fullrect;
+        }
+
+        w = dstrect12->w;
+        h = dstrect12->h;
 
         dstalpha = (Uint8 *) SDL20_malloc(w * h);
         if (!dstalpha) {
@@ -6210,14 +6218,23 @@ static void
 RestoreDestAlpha(SDL12_Surface *dst12, Uint8 *dstalpha, const SDL12_Rect *dstrect12)
 {
     if (dstalpha) {
-        int x, y;
-
-        const int w = dstrect12->w;
-        const int h = dstrect12->h;
         const Uint8 *sptr = dstalpha;
         const Uint32 amask = dst12->format->Amask;
         const Uint32 ashift = dst12->format->Ashift;
         const Uint16 pitch = dst12->pitch;
+        SDL12_Rect fullrect;
+        int x, y, w, h;
+
+        if (!dstrect12) {
+            fullrect.x = 0;
+            fullrect.y = 0;
+            fullrect.w = dst12->w;
+            fullrect.h = dst12->h;
+            dstrect12 = &fullrect;
+        }
+
+        w = dstrect12->w;
+        h = dstrect12->h;
 
         if (dst12->format->BytesPerPixel == 2) {
             Uint16 *dptr = (Uint16 *) dst12->pixels;