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.
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,