summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-03-01 13:54:38 +1000
committerBen Skeggs <bskeggs@redhat.com>2011-03-01 13:54:38 +1000
commitace98a492353e6de712f4f717e6d3f562e3591f0 (patch)
tree96326622e7b1e2d292d89889cceca923d0c8aa09 /src
parentbc5dec2ca7ca7edc340a99bd73946e228117dfd8 (diff)
dri2: return an error rather than crashing if we can't allocate a buffer
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/nouveau_dri2.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/nouveau_dri2.c b/src/nouveau_dri2.c
index d5afa8a..1a68ed3 100644
--- a/src/nouveau_dri2.c
+++ b/src/nouveau_dri2.c
@@ -29,6 +29,7 @@ nouveau_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
ScreenPtr pScreen = pDraw->pScreen;
NVPtr pNv = NVPTR(xf86Screens[pScreen->myNum]);
struct nouveau_dri2_buffer *nvbuf;
+ struct nouveau_pixmap *nvpix;
PixmapPtr ppix;
nvbuf = calloc(1, sizeof(*nvbuf));
@@ -70,7 +71,14 @@ nouveau_dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment,
nvbuf->base.flags = 0;
nvbuf->ppix = ppix;
- nouveau_bo_handle_get(nouveau_pixmap(ppix)->bo, &nvbuf->base.name);
+ nvpix = nouveau_pixmap(ppix);
+ if (!nvpix || !nvpix->bo ||
+ nouveau_bo_handle_get(nvpix->bo, &nvbuf->base.name)) {
+ pScreen->DestroyPixmap(nvbuf->ppix);
+ free(nvbuf);
+ return NULL;
+ }
+
return &nvbuf->base;
}