From dfc7535ff7e4e975c41619e64ee3f75a80fe308d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 26 Jul 2014 16:52:26 -0700 Subject: [PATCH] Fixed bug 2657 - Memory leak in GL_CreateTexture function Nitz In GL_CreateTexture function: if (GL_CheckError("glGenTexures()", renderer) < 0) { SDL_free(data); return -1; } Here only data is getting free but data->pixels getting leak. So have to free data->pixels before free data. --- src/render/opengl/SDL_render_gl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index a23d4f03b..e1c78cb8b 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -688,6 +688,9 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) GL_CheckError("", renderer); renderdata->glGenTextures(1, &data->texture); if (GL_CheckError("glGenTexures()", renderer) < 0) { + if (data->pixels) { + SDL_free(data->pixels); + } SDL_free(data); return -1; }