Fix memory leaks in X11_CreateDevice error paths
authorSam Lantinga
Wed, 18 Jul 2012 14:48:32 -0700
changeset 63673c1253baeaec
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
     1.1 --- a/src/video/x11/SDL_x11video.c	Wed Jul 18 13:57:39 2012 -0700
     1.2 +++ b/src/video/x11/SDL_x11video.c	Wed Jul 18 14:48:32 2012 -0700
     1.3 @@ -148,6 +148,8 @@
     1.4      device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
     1.5      if (!device->gles_data) {
     1.6          SDL_OutOfMemory();
     1.7 +        SDL_free(device->driverdata);
     1.8 +        SDL_free(device);
     1.9          return NULL;
    1.10      }
    1.11  #endif
    1.12 @@ -175,6 +177,10 @@
    1.13      }
    1.14  #endif
    1.15      if (data->display == NULL) {
    1.16 +#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
    1.17 +        SDL_free(device->gles_data);
    1.18 +#endif
    1.19 +        SDL_free(device->driverdata);
    1.20          SDL_free(device);
    1.21          SDL_SetError("Couldn't open X11 display");
    1.22          return NULL;