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
|
@ -1241,8 +1241,7 @@ GL_DestroyRenderer(SDL_Renderer * renderer)
|
||||||
GL_CheckError("", renderer);
|
GL_CheckError("", renderer);
|
||||||
SDL_free(data->framebuffers);
|
SDL_free(data->framebuffers);
|
||||||
data->framebuffers = nextnode;
|
data->framebuffers = nextnode;
|
||||||
}
|
}
|
||||||
/* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */
|
|
||||||
SDL_GL_DeleteContext(data->context);
|
SDL_GL_DeleteContext(data->context);
|
||||||
}
|
}
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
|
|
|
@ -2690,13 +2690,14 @@ SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
CHECK_WINDOW_MAGIC(window, -1);
|
|
||||||
|
|
||||||
if (!(window->flags & SDL_WINDOW_OPENGL)) {
|
|
||||||
return SDL_SetError("The specified window isn't an OpenGL window");
|
|
||||||
}
|
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
window = NULL;
|
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 ((window == _this->current_glwin) && (ctx == _this->current_glctx)) {
|
if ((window == _this->current_glwin) && (ctx == _this->current_glctx)) {
|
||||||
|
@ -2758,7 +2759,11 @@ SDL_GL_DeleteContext(SDL_GLContext context)
|
||||||
if (!_this || !context) {
|
if (!_this || !context) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_this->GL_MakeCurrent(_this, NULL, NULL);
|
|
||||||
|
if (_this->current_glctx == context) {
|
||||||
|
SDL_GL_MakeCurrent(NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
_this->GL_DeleteContext(_this, context);
|
_this->GL_DeleteContext(_this, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue