r300g: prevent NULL pointer dereference in r300_buffer_create
authorMarek Olšák <maraeo@gmail.com>
Fri, 11 Feb 2011 02:17:04 +0000 (03:17 +0100)
committerMarek Olšák <maraeo@gmail.com>
Fri, 11 Feb 2011 02:18:05 +0000 (03:18 +0100)
Should fix:
https://bugs.freedesktop.org/show_bug.cgi?id=33185

src/gallium/drivers/r300/r300_screen_buffer.c

index 2e85e2d6ffbf88f46ab9ea687b720c9c06c21028..04afae609f9225187ddb7235613bc6ff2e096901 100644 (file)
@@ -226,14 +226,14 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
                                        rbuf->b.b.b.width0, alignment,
                                        rbuf->b.b.b.bind, rbuf->b.b.b.usage,
                                        rbuf->domain);
-    rbuf->cs_buf =
-        r300screen->rws->buffer_get_cs_handle(rbuf->buf);
-
     if (!rbuf->buf) {
         util_slab_free(&r300screen->pool_buffers, rbuf);
         return NULL;
     }
 
+    rbuf->cs_buf =
+        r300screen->rws->buffer_get_cs_handle(rbuf->buf);
+
     return &rbuf->b.b.b;
 }