Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix memory leaks in X11_CreateDevice error paths

Patch contributed by Andre Heider
  • Loading branch information
slouken committed Jul 18, 2012
1 parent a3b2a2d commit 5010fb4be58b4c4b0b50c9ceb9cb66dcb1bd8f31
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/video/x11/SDL_x11video.c
@@ -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
@@ -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;

0 comments on commit 5010fb4

Please sign in to comment.