wayland: Destroy frame callback when destroying surface

If a frame callback is not destroyed when destroying a surface, its
handler function will be invoked if the surface was destroyed after the
callback was requested but before it was invoked, causing a write on
free:ed memory.

This can happen if eglDestroySurface() is called shortly after
eglSwapBuffers().

Note: This is a candidate for stable branches.

Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
This commit is contained in:
Jonas Ådahl 2012-10-28 00:50:12 +02:00 committed by Kristian Høgsberg
parent 0b61f0b148
commit a3b6b2d305
2 changed files with 6 additions and 0 deletions

View file

@ -213,6 +213,9 @@ dri2_destroy_surface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf)
dri2_surf->third_buffer);
}
if (dri2_surf->frame_callback)
wl_callback_destroy(dri2_surf->frame_callback);
free(surf);
return EGL_TRUE;

View file

@ -355,6 +355,9 @@ wayland_surface_destroy(struct native_surface *nsurf)
wl_buffer_destroy(surface->buffer[buffer]);
}
if (surface->frame_callback)
wl_callback_destroy(surface->frame_callback);
resource_surface_destroy(surface->rsurf);
FREE(surface);
}