Fixed bug 2657 - Memory leak in GL_CreateTexture function
authorSam Lantinga <slouken@libsdl.org>
Sat, 26 Jul 2014 16:52:26 -0700
changeset 9011c3591f14ab7e
parent 9010 6d059ed9b6ca
child 9012 aa058c87737b
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
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Tue Jul 22 23:12:21 2014 -0400
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Sat Jul 26 16:52:26 2014 -0700
     1.3 @@ -688,6 +688,9 @@
     1.4      GL_CheckError("", renderer);
     1.5      renderdata->glGenTextures(1, &data->texture);
     1.6      if (GL_CheckError("glGenTexures()", renderer) < 0) {
     1.7 +        if (data->pixels) {
     1.8 +            SDL_free(data->pixels);
     1.9 +        }
    1.10          SDL_free(data);
    1.11          return -1;
    1.12      }