diff options
author | Jelle Raaijmakers <jelle@gmta.nl> | 2021-12-01 23:10:12 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-12-12 21:51:08 +0100 |
commit | b79642ef742dd7681f732343dcdb63970ad733d5 (patch) | |
tree | 5a0fecf734f4c416f4e2e5e115865806d947b130 /Userland/Libraries/LibGL/GLUtils.cpp | |
parent | a06b69c5b5c192e7db5bf20afa0c8e25900f8fa2 (diff) | |
download | serenity-b79642ef742dd7681f732343dcdb63970ad733d5.zip |
LibGL: Support missing context in `glGetError` and `glGetIntegerv`
In its current state, ScummVM seems to invoke these methods just after
destroying the current GL context. According to the OpenGL spec:
"Issuing GL commands when the program does not have a current
context results in undefined behavior, up to and including program
termination."
Our old behavior was to deref a `nullptr`, which isn't that great. For
now, protect these two methods. If other ports seem to misbehave as
well, we can always expand the check to other methods.
Diffstat (limited to 'Userland/Libraries/LibGL/GLUtils.cpp')
-rw-r--r-- | Userland/Libraries/LibGL/GLUtils.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGL/GLUtils.cpp b/Userland/Libraries/LibGL/GLUtils.cpp index b580730c72..253d2f4cae 100644 --- a/Userland/Libraries/LibGL/GLUtils.cpp +++ b/Userland/Libraries/LibGL/GLUtils.cpp @@ -67,6 +67,7 @@ void glViewport(GLint x, GLint y, GLsizei width, GLsizei height) GLenum glGetError() { + VERIFY_CURRENT_CONTEXT_OR_VALUE(GL_NONE); return g_gl_context->gl_get_error(); } @@ -117,6 +118,7 @@ void glGetFloatv(GLenum pname, GLfloat* params) void glGetIntegerv(GLenum pname, GLint* data) { + VERIFY_CURRENT_CONTEXT(); g_gl_context->gl_get_integerv(pname, data); } |