Skip to content

Commit

Permalink
Fix potential memory leak in GLES_CreateTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiaoafeifei authored and slouken committed Sep 21, 2022
1 parent 301912a commit 00b67f5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/render/opengles/SDL_render_gles.c
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 00b67f5

Please sign in to comment.