summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-04-11 14:28:29 +0200
committerGitHub <noreply@github.com>2021-04-11 14:28:29 +0200
commit5644c00482ce2ca43e0f46f3ed40993599bb5707 (patch)
treeb12fa284107d4dffbaaa20d572dff328489f8769 /src/video
parentd50b934bb416a96cfdc517d703ef0795d4d0424b (diff)
downloadopenttd-5644c00482ce2ca43e0f46f3ed40993599bb5707.tar.xz
Fix: Check for a validly mapped OpenGL screen buffer during driver init. (#9007)
Diffstat (limited to 'src/video')
-rw-r--r--src/video/sdl2_opengl_v.cpp5
-rw-r--r--src/video/win32_v.cpp6
2 files changed, 11 insertions, 0 deletions
diff --git a/src/video/sdl2_opengl_v.cpp b/src/video/sdl2_opengl_v.cpp
index 08718a01e..202593e64 100644
--- a/src/video/sdl2_opengl_v.cpp
+++ b/src/video/sdl2_opengl_v.cpp
@@ -69,6 +69,11 @@ const char *VideoDriver_SDL_OpenGL::Start(const StringList &param)
int w, h;
SDL_GetWindowSize(this->sdl_window, &w, &h);
this->ClientSizeChanged(w, h, true);
+ /* We should have a valid screen buffer now. If not, something went wrong and we should abort. */
+ if (_screen.dst_ptr == nullptr) {
+ this->Stop();
+ return "Can't get pointer to screen buffer";
+ }
return nullptr;
}
diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp
index 467478461..08ab27c53 100644
--- a/src/video/win32_v.cpp
+++ b/src/video/win32_v.cpp
@@ -1305,6 +1305,12 @@ const char *VideoDriver_Win32OpenGL::Start(const StringList &param)
}
this->ClientSizeChanged(this->width, this->height, true);
+ /* We should have a valid screen buffer now. If not, something went wrong and we should abort. */
+ if (_screen.dst_ptr == nullptr) {
+ this->Stop();
+ _cur_resolution = old_res;
+ return "Can't get pointer to screen buffer";
+ }
MarkWholeScreenDirty();