Commit b9f55b6d805446856b435b76442c59711603aef9

Sam Lantinga 2020-06-19T10:37:14

Fixed bug 5199 - Fix KMSDRM_CreateWindow() segfault when starting L?VE2D engine. Manuel Alfayate Corchete This small patch fixes the KMSDRM_CreateSurfaces() call in KMSDRM_CreateWindow(), that was segfaulting deeper into SDL internals because the windata->viddata pointer wasn't set before the KMSDRM_CreateSurfaces() call. So that's what this small patch does. Now, L?VE2D works perfectly well on the Raspberry Pi 3, instead of just segfaulting.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c
index e00f959..710a6a0 100644
--- a/src/video/kmsdrm/SDL_kmsdrmvideo.c
+++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c
@@ -798,6 +798,7 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
     }
 
     /* Setup driver data for this window */
+    windata->viddata = viddata;
     window->driverdata = windata;
 
     if (KMSDRM_CreateSurfaces(_this, window)) {
@@ -807,8 +808,6 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window)
     /* Add window to the internal list of tracked windows. Note, while it may
        seem odd to support multiple fullscreen windows, some apps create an
        extra window as a dummy surface when working with multiple contexts */
-    windata->viddata = viddata;
-
     if (viddata->num_windows >= viddata->max_windows) {
         int new_max_windows = viddata->max_windows + 1;
         viddata->windows = (SDL_Window **)SDL_realloc(viddata->windows,