sdl2-compat: surface: sync SDL3 surface on free

From 1c8ece4de9db96d01f99296c26a87a4cabb72f54 Mon Sep 17 00:00:00 2001
From: Cameron Gutman <[EMAIL REDACTED]>
Date: Wed, 21 Jan 2026 22:53:31 -0600
Subject: [PATCH] surface: sync SDL3 surface on free

If the app doesn't call any surface functions prior to calling
SDL_FreeSurface(), changes made to the SDL2 surface will not be
propagated to the SDL3 surface. This may cause the pixel data to
be leaked or freed incorrectly.

Pixel data for surfaces allocated by SDL_ttf was being leaked as
a result of this bug.
---
 src/sdl2_compat.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index e55e5acd..7997c2ca 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -4417,8 +4417,7 @@ SDL_FreeSurface(SDL2_Surface *surface)
     }
 
     if (surface->map) {
-        SDL_Surface *surface3 = (SDL_Surface *)surface->map;
-        SDL3_DestroySurface(surface3);
+        SDL3_DestroySurface(Surface2to3(surface));
         surface->map = NULL;
     }