diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c index ed7fdd6..aba5e8d 100644 --- a/src/radeon_dri2.c +++ b/src/radeon_dri2.c @@ -166,20 +166,9 @@ radeon_dri2_create_buffer(DrawablePtr drawable, struct dri2_buffer_priv *privates; PixmapPtr pixmap, depth_pixmap; struct radeon_exa_pixmap_priv *driver_priv; - int r; int flags; - 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) { @@ -226,6 +215,15 @@ radeon_dri2_create_buffer(DrawablePtr drawable, flags); } + if (!pixmap) { + return NULL; + } + + buffers = calloc(1, sizeof *buffers); + if (buffers == NULL) { + return NULL; + } + if (attachment == DRI2BufferDepth) { depth_pixmap = pixmap; } @@ -233,9 +231,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;