Fixed bug 5007 - Segfault in KMSDRM_VideoQuit() on Raspberry Pi Zero with no display attached

Charles Huber

This patch fixes the segfault on my Pi, though the valid display index range reported by the CHECK_DISPLAY_INDEX() macro in src/video/SDL_video.c is a little weird:

$ SDL_VIDEO_EGL_DRIVER=libEGL.so SDL_VIDEO_GL_DRIVER=libGLESv2.so ./a.out
SDL_Init(): displayIndex must be in the range 0 - -1
This commit is contained in:
Sam Lantinga 2020-03-02 14:55:40 -08:00
parent f00ddd0a38
commit a19757ac8d

View File

@ -650,7 +650,7 @@ KMSDRM_VideoQuit(_THIS)
viddata->num_windows = 0;
/* Restore saved CRTC settings */
if (viddata->drm_fd >= 0 && dispdata->conn && dispdata->saved_crtc) {
if (viddata->drm_fd >= 0 && dispdata && dispdata->conn && dispdata->saved_crtc) {
drmModeConnector *conn = dispdata->conn;
drmModeCrtc *crtc = dispdata->saved_crtc;
@ -661,11 +661,11 @@ KMSDRM_VideoQuit(_THIS)
SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not restore original CRTC mode");
}
}
if (dispdata->conn) {
if (dispdata && dispdata->conn) {
KMSDRM_drmModeFreeConnector(dispdata->conn);
dispdata->conn = NULL;
}
if (dispdata->saved_crtc) {
if (dispdata && dispdata->saved_crtc) {
KMSDRM_drmModeFreeCrtc(dispdata->saved_crtc);
dispdata->saved_crtc = NULL;
}