Fix potential memory leak in GLES_CreateTexture

This commit is contained in:
zhailiangliang 2022-09-21 10:30:38 +08:00 committed by Sam Lantinga
parent 301912a5b9
commit 00b67f5572

View file

@ -359,6 +359,9 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
renderdata->glGenTextures(1, &data->texture);
result = renderdata->glGetError();
if (result != GL_NO_ERROR) {
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
SDL_free(data->pixels);
}
SDL_free(data);
return GLES_SetError("glGenTextures()", result);
}
@ -387,6 +390,9 @@ GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
result = renderdata->glGetError();
if (result != GL_NO_ERROR) {
if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
SDL_free(data->pixels);
}
SDL_free(data);
return GLES_SetError("glTexImage2D()", result);
}