SDL_GL_DeleteContext would leave an invalid current_glctx.
Calling SDL_GL_DeleteContext wouldn't update current_glctx, so you could end up with use-after-free and other goodies when you deleted a context.
This commit is contained in:
parent
5a4c9c40f2
commit
187143d618
2 changed files with 12 additions and 8 deletions
|
@ -1242,7 +1242,6 @@ GL_DestroyRenderer(SDL_Renderer * renderer)
|
|||
SDL_free(data->framebuffers);
|
||||
data->framebuffers = nextnode;
|
||||
}
|
||||
/* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
}
|
||||
SDL_free(data);
|
||||
|
|
|
@ -2690,13 +2690,14 @@ SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx)
|
|||
{
|
||||
int retval;
|
||||
|
||||
if (!ctx) {
|
||||
window = NULL;
|
||||
} else {
|
||||
CHECK_WINDOW_MAGIC(window, -1);
|
||||
|
||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
||||
return SDL_SetError("The specified window isn't an OpenGL window");
|
||||
}
|
||||
if (!ctx) {
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
if ((window == _this->current_glwin) && (ctx == _this->current_glctx)) {
|
||||
|
@ -2758,7 +2759,11 @@ SDL_GL_DeleteContext(SDL_GLContext context)
|
|||
if (!_this || !context) {
|
||||
return;
|
||||
}
|
||||
_this->GL_MakeCurrent(_this, NULL, NULL);
|
||||
|
||||
if (_this->current_glctx == context) {
|
||||
SDL_GL_MakeCurrent(NULL, NULL);
|
||||
}
|
||||
|
||||
_this->GL_DeleteContext(_this, context);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue