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.
This commit is contained in:
Sam Lantinga 2014-07-26 16:52:26 -07:00
parent 987c335551
commit dfc7535ff7

View file

@ -688,6 +688,9 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
GL_CheckError("", renderer); GL_CheckError("", renderer);
renderdata->glGenTextures(1, &data->texture); renderdata->glGenTextures(1, &data->texture);
if (GL_CheckError("glGenTexures()", renderer) < 0) { if (GL_CheckError("glGenTexures()", renderer) < 0) {
if (data->pixels) {
SDL_free(data->pixels);
}
SDL_free(data); SDL_free(data);
return -1; return -1;
} }