Fix memory leaks in X11_CreateDevice error paths
Patch contributed by Andre Heider
--- a/src/video/x11/SDL_x11video.c Wed Jul 18 13:57:39 2012 -0700
+++ b/src/video/x11/SDL_x11video.c Wed Jul 18 14:48:32 2012 -0700
@@ -148,6 +148,8 @@
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 @@
}
#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;