st/egl: Fix a crash when unbinding current context.

This fixes a NULL-pointer dereference when
eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)
is called.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
Chia-I Wu 2009-09-30 11:32:36 +08:00 committed by Brian Paul
parent fa8df0c40d
commit dd81cc885c
3 changed files with 4 additions and 14 deletions

View File

@ -160,18 +160,12 @@ drm_make_current(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw, _EGLSurfa
if (!drawSurf || !readSurf)
return EGL_FALSE;
drawSurf->user = ctx;
readSurf->user = ctx;
st_make_current(ctx->st, drawSurf->stfb, readSurf->stfb);
/* st_resize_framebuffer needs a bound context to work */
st_resize_framebuffer(drawSurf->stfb, drawSurf->w, drawSurf->h);
st_resize_framebuffer(readSurf->stfb, readSurf->w, readSurf->h);
} else {
drawSurf->user = NULL;
readSurf->user = NULL;
st_make_current(NULL, NULL, NULL);
}

View File

@ -352,24 +352,21 @@ drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
if (!surf)
return EGL_FALSE;
/* error checking */
if (!_eglSwapBuffers(drv, dpy, draw))
return EGL_FALSE;
st_get_framebuffer_surface(surf->stfb, ST_SURFACE_BACK_LEFT, &back_surf);
if (back_surf) {
struct drm_context *ctx = lookup_drm_context(draw->Binding);
st_notify_swapbuffers(surf->stfb);
if (surf->screen) {
surf->user->pipe->surface_copy(surf->user->pipe,
if (ctx && surf->screen) {
ctx->pipe->surface_copy(ctx->pipe,
surf->screen->surface,
0, 0,
back_surf,
0, 0,
surf->w, surf->h);
surf->user->pipe->flush(surf->user->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL);
#ifdef DRM_MODE_FEATURE_DIRTYFB
/* TODO query connector property to see if this is needed */

View File

@ -69,7 +69,6 @@ struct drm_surface
* drm
*/
struct drm_context *user;
struct drm_screen *screen;
int w;