SDL: Do not store pointer before potentialy freeing it

From 4d00706f57284b0072d18d7dc873012aa13f32a5 Mon Sep 17 00:00:00 2001
From: Mathieu Eyraud <[EMAIL REDACTED]>
Date: Sat, 30 Mar 2024 18:59:19 +0100
Subject: [PATCH] Do not store pointer before potentialy freeing it

Store data to windows->driverdata after call to SetProp() in case it fails.
---
 src/video/windows/SDL_windowswindow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 78171f7e7a3d9..ee20396f75d25 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -388,8 +388,6 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
 
     SDL_AddHintCallback(SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, WIN_MouseRelativeModeCenterChanged, data);
 
-    window->driverdata = data;
-
 #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
     /* Associate the data with the window */
     if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) {
@@ -398,6 +396,8 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd
         return WIN_SetError("SetProp() failed");
     }
 #endif
+    
+    window->driverdata = data;
 
     /* Set up the window proc function */
 #ifdef GWLP_WNDPROC