diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index 46573a7..2dbcdc9 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -232,7 +232,7 @@ radeon_dri2_create_buffer(DrawablePtr drawable, struct dri2_buffer_priv *privates; PixmapPtr pixmap, depth_pixmap; struct radeon_exa_pixmap_priv *driver_priv; - int r, need_enlarge = 0; + int need_enlarge = 0; int flags; unsigned front_width; uint32_t tiling = 0; @@ -240,17 +240,7 @@ radeon_dri2_create_buffer(DrawablePtr drawable, pixmap = pScreen->GetScreenPixmap(pScreen); front_width = pixmap->drawable.width; - buffers = calloc(1, sizeof *buffers); - if (buffers == NULL) { - return NULL; - } - privates = calloc(1, sizeof(struct dri2_buffer_priv)); - if (privates == NULL) { - free(buffers); - return NULL; - } - - depth_pixmap = NULL; + pixmap = depth_pixmap = NULL; if (attachment == DRI2BufferFrontLeft) { if (drawable->type == DRAWABLE_PIXMAP) { @@ -351,6 +341,15 @@ radeon_dri2_create_buffer(DrawablePtr drawable, } } + if (!pixmap) { + return NULL; + } + + buffers = calloc(1, sizeof *buffers); + if (buffers == NULL) { + return NULL; + } + if (attachment == DRI2BufferDepth) { depth_pixmap = pixmap; } @@ -358,9 +357,17 @@ radeon_dri2_create_buffer(DrawablePtr drawable, exaMoveInPixmap(pixmap); info->exa_force_create = FALSE; driver_priv = exaGetPixmapDriverPrivate(pixmap); - r = radeon_gem_get_kernel_name(driver_priv->bo, &buffers->name); - if (r) - return NULL; + if (!driver_priv || + (radeon_gem_get_kernel_name(driver_priv->bo, &buffers->name) != 0)) { + free(buffers); + return NULL; + } + + privates = calloc(1, sizeof(struct dri2_buffer_priv)); + if (privates == NULL) { + free(buffers); + return NULL; + } buffers->attachment = attachment; buffers->pitch = pixmap->devKind;