st/egl: Fix a crash when unbinding current context.
authorChia-I Wu <olvaffe@gmail.com>
Wed, 30 Sep 2009 03:32:36 +0000 (11:32 +0800)
committerBrian Paul <brianp@vmware.com>
Wed, 30 Sep 2009 14:15:30 +0000 (08:15 -0600)
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>
src/gallium/state_trackers/egl/egl_context.c
src/gallium/state_trackers/egl/egl_surface.c
src/gallium/state_trackers/egl/egl_tracker.h

index c4f7361ca0b1f32c4b92d75095585de8836a5388..288186ad72e81da345c627f1d7440e21348cb9e8 100644 (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);
        }
 
index 542ac56121ccd91fa356afe7b7364d7ffe0a01db..7911a8834e01576c888d34332d4c7d888043f86b 100644 (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 */
index f280748d6525617e33d7f5825a57d964f00b9f86..73eb1a1226ee04cb782b35d2847d9a5934674530 100644 (file)
@@ -69,7 +69,6 @@ struct drm_surface
         * drm
         */
 
-       struct drm_context *user;
        struct drm_screen *screen;
 
        int w;