mirror of https://github.com/encounter/SDL.git
Fix crash when GL_LoadFunctions()/GLES2_LoadFunctions() fails
https://bugzilla.libsdl.org/show_bug.cgi?id=4350 We can't safely call GL_DestroyRenderer() until GL_LoadFunctions() succeeds because we will be missing functions that we try to use when activating the renderer for destruction if we have an GL context.
This commit is contained in:
parent
aeee424f65
commit
329f2eb99e
|
@ -420,7 +420,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
|
||||
data = (GL_RenderData *) SDL_calloc(1, sizeof(*data));
|
||||
if (!data) {
|
||||
GL_DestroyRenderer(renderer);
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
@ -455,16 +455,21 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
|||
|
||||
data->context = SDL_GL_CreateContext(window);
|
||||
if (!data->context) {
|
||||
GL_DestroyRenderer(renderer);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_MakeCurrent(window, data->context) < 0) {
|
||||
GL_DestroyRenderer(renderer);
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (GL_LoadFunctions(data) < 0) {
|
||||
GL_DestroyRenderer(renderer);
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
|
@ -2122,7 +2122,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
|
||||
data = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext));
|
||||
if (!data) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_free(renderer);
|
||||
SDL_OutOfMemory();
|
||||
goto error;
|
||||
}
|
||||
|
@ -2134,16 +2134,21 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
|||
/* Create an OpenGL ES 2.0 context */
|
||||
data->context = SDL_GL_CreateContext(window);
|
||||
if (!data->context) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
if (SDL_GL_MakeCurrent(window, data->context) < 0) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (GLES2_LoadFunctions(data) < 0) {
|
||||
GLES2_DestroyRenderer(renderer);
|
||||
SDL_GL_DeleteContext(data->context);
|
||||
SDL_free(renderer);
|
||||
SDL_free(data);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue