diff --git a/glamor/glamor_largepixmap.c b/glamor/glamor_largepixmap.c index 3467eb800..d8aa2e6d4 100644 --- a/glamor/glamor_largepixmap.c +++ b/glamor/glamor_largepixmap.c @@ -82,6 +82,10 @@ __glamor_compute_clipped_regions(int block_w, clipped_regions = calloc((end_block_x - start_block_x + 1) * (end_block_y - start_block_y + 1), sizeof(*clipped_regions)); + if (!clipped_regions) { + *n_region = 0; + return NULL; + } DEBUGF("startx %d starty %d endx %d endy %d \n", start_x, start_y, end_x, end_y); @@ -222,6 +226,11 @@ glamor_compute_clipped_regions_ext(PixmapPtr pixmap, inner_block_w) * ((block_h + inner_block_h - 1) / inner_block_h), sizeof(*result_regions)); + if (!result_regions) { + *n_region = 0; + return NULL; + } + k = 0; for (i = 0; i < *n_region; i++) { x = box_array[clipped_regions[i].block_idx].x1; @@ -368,6 +377,11 @@ _glamor_compute_clipped_regions(PixmapPtr pixmap, DEBUGRegionPrint(region); if (glamor_pixmap_priv_is_small(pixmap_priv)) { clipped_regions = calloc(1, sizeof(*clipped_regions)); + if (!clipped_regions) { + *n_region = 0; + return NULL; + } + clipped_regions[0].region = RegionCreate(NULL, 1); clipped_regions[0].block_idx = 0; RegionCopy(clipped_regions[0].region, region);