Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fix memory leaks in X11_CreateDevice error paths
Browse files Browse the repository at this point in the history
Patch contributed by Andre Heider
  • Loading branch information
slouken committed Jul 18, 2012
1 parent a3b2a2d commit 5010fb4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -148,6 +148,8 @@ X11_CreateDevice(int devindex)
device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
if (!device->gles_data) {
SDL_OutOfMemory();
SDL_free(device->driverdata);
SDL_free(device);
return NULL;
}
#endif
Expand Down Expand Up @@ -175,6 +177,10 @@ X11_CreateDevice(int devindex)
}
#endif
if (data->display == NULL) {
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
SDL_free(device->gles_data);
#endif
SDL_free(device->driverdata);
SDL_free(device);
SDL_SetError("Couldn't open X11 display");
return NULL;
Expand Down

0 comments on commit 5010fb4

Please sign in to comment.