radeon: avoid segfault in radeon_update_renderbuffers() if using DRI1
authorTormod Volden <debian.tormod@gmail.com>
Tue, 12 May 2009 07:32:11 +0000 (09:32 +0200)
committerJerome Glisse <glisse@freedesktop.org>
Tue, 12 May 2009 10:43:08 +0000 (12:43 +0200)
Basically the same as 43d9020ff1e975e7f4f9480d9ef24f0b9fb2141f for intel. Bug 21688.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
src/mesa/drivers/dri/radeon/radeon_common_context.c

index 124b587bab15f6b1834e071ca953d252effd337b..6fb6f92cb94d16d3f33ab17d6a136659e653ddc1 100644 (file)
@@ -428,7 +428,7 @@ void
 radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
 {
        unsigned int attachments[10];
-       __DRIbuffer *buffers;
+       __DRIbuffer *buffers = NULL;
        __DRIscreen *screen;
        struct radeon_renderbuffer *rb;
        int i, count;
@@ -444,7 +444,8 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
        screen = context->driScreenPriv;
        radeon = (radeonContextPtr) context->driverPrivate;
 
-       if ((screen->dri2.loader->base.version > 2)
+       if (screen->dri2.loader
+          && (screen->dri2.loader->base.version > 2)
           && (screen->dri2.loader->getBuffersWithFormat != NULL)) {
                struct radeon_renderbuffer *depth_rb;
                struct radeon_renderbuffer *stencil_rb;
@@ -481,7 +482,7 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
                                                                attachments, i / 2,
                                                                &count,
                                                                drawable->loaderPrivate);
-       } else {
+       } else if (screen->dri2.loader) {
                i = 0;
                if (draw->color_rb[0])
                        attachments[i++] = __DRI_BUFFER_FRONT_LEFT;