From dd81cc885c3d0619921a7de7e00618e412c05697 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 30 Sep 2009 11:32:36 +0800 Subject: [PATCH] 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 --- src/gallium/state_trackers/egl/egl_context.c | 6 ------ src/gallium/state_trackers/egl/egl_surface.c | 11 ++++------- src/gallium/state_trackers/egl/egl_tracker.h | 1 - 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c index c4f7361ca0b..288186ad72e 100644 --- a/src/gallium/state_trackers/egl/egl_context.c +++ b/src/gallium/state_trackers/egl/egl_context.c @@ -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); } diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index 542ac56121c..7911a8834e0 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -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 */ diff --git a/src/gallium/state_trackers/egl/egl_tracker.h b/src/gallium/state_trackers/egl/egl_tracker.h index f280748d652..73eb1a1226e 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.h +++ b/src/gallium/state_trackers/egl/egl_tracker.h @@ -69,7 +69,6 @@ struct drm_surface * drm */ - struct drm_context *user; struct drm_screen *screen; int w; -- 2.30.2