Fix memory leaks in X11_CreateDevice error paths
authorSam Lantinga <slouken@libsdl.org>
Wed, 18 Jul 2012 14:48:32 -0700
changeset 6367 3c1253baeaec
parent 6365 975e23e06124
child 6368 fcbbd0e2da5e
Fix memory leaks in X11_CreateDevice error paths Patch contributed by Andre Heider
src/video/x11/SDL_x11video.c
--- 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;