diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index f3e8326ac..09db12de8 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -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; } diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index fe51b9aaf..f21a95762 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -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; }