egl_dri2: fix aux buffer leak in drm platform
authorMandeep Singh Baines <mandeep.baines@gmail.com>
Tue, 10 Apr 2012 21:48:14 +0000 (14:48 -0700)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 10 Apr 2012 23:08:12 +0000 (19:08 -0400)
Keep a reference to any newly allocated aux buffers to avoid
re-allocating for every st_framebuffer_validate() (i.e. leaking).

Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
src/egl/drivers/dri2/platform_drm.c

index 18ecd173f4ede66a6ab7beba0974876b068e5ab7..54067ff78146decc87de25ce9720ee358b81126f 100644 (file)
@@ -220,16 +220,15 @@ get_aux_bo(struct dri2_egl_surface *dri2_surf,
 {
    struct dri2_egl_display *dri2_dpy =
       dri2_egl_display(dri2_surf->base.Resource.Display);
-   __DRIbuffer *b;
+   __DRIbuffer *b = dri2_surf->dri_buffers[attachment];
 
-   b = NULL;
-   if (dri2_surf->dri_buffers[attachment])
-      b = dri2_surf->dri_buffers[attachment];
-   if (b == NULL)
+   if (b == NULL) {
       b = dri2_dpy->dri2->allocateBuffer(dri2_dpy->dri_screen,
                                         attachment, format,
                                         dri2_surf->base.Width,
                                         dri2_surf->base.Height);
+      dri2_surf->dri_buffers[attachment] = b;
+   }
    if (b == NULL)
       return -1;