SDL: WIN_GetDrawableSize: avoid NULL pointer dereference

From 4726270ead9b2711c37af33433bb10e6256c7c5c Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 8 Oct 2022 23:01:28 +0300
Subject: [PATCH] WIN_GetDrawableSize: avoid NULL pointer dereference

Fixes https://github.com/libsdl-org/SDL/issues/6356
---
 src/video/windows/SDL_windowswindow.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index eb536bbe4693..3fd329019b23 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -1408,10 +1408,16 @@ WIN_SetWindowOpacity(_THIS, SDL_Window * window, float opacity)
 void
 WIN_GetDrawableSize(const SDL_Window *window, int *w, int *h)
 {
-    const SDL_WindowData *data = ((SDL_WindowData *)window->driverdata);
-    HWND hwnd = data->hwnd;
+    HWND hwnd;
     RECT rect;
 
+    if (!window || !(window->driverdata)) {
+        *w = 0;
+        *h = 0;
+        return;
+    }
+
+    hwnd = ((SDL_WindowData *)window->driverdata)->hwnd;
     if (GetClientRect(hwnd, &rect)) {
         *w = rect.right;
         *h = rect.bottom;