From ace98a492353e6de712f4f717e6d3f562e3591f0 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Tue, 1 Mar 2011 13:54:38 +1000 Subject: dri2: return an error rather than crashing if we can't allocate a buffer Signed-off-by: Ben Skeggs --- src/nouveau_dri2.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') 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; } -- cgit v1.2.3