From 325dce226c72cf48fe7343f481df065f3b1d766a Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Thu, 4 Dec 2008 14:13:24 +0100 Subject: [PATCH] isl_map.c: avoid potential NULL dereference --- include/isl_ctx.h.in | 1 + isl_map.c | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/isl_ctx.h.in b/include/isl_ctx.h.in index 070cd53..7aac125 100644 --- a/include/isl_ctx.h.in +++ b/include/isl_ctx.h.in @@ -68,6 +68,7 @@ struct isl_ctx { #define isl_alloc_type(ctx,type) isl_alloc(ctx,type,sizeof(type)) #define isl_realloc_type(ctx,ptr,type) isl_realloc(ctx,ptr,type,sizeof(type)) #define isl_alloc_array(ctx,type,n) isl_alloc(ctx,type,(n)*sizeof(type)) +#define isl_calloc_array(ctx,type,n) (type *)calloc(n, sizeof(type)) #define isl_realloc_array(ctx,ptr,type,n) \ isl_realloc(ctx,ptr,type,(n)*sizeof(type)) diff --git a/isl_map.c b/isl_map.c index ff5f34e..5abfe3b 100644 --- a/isl_map.c +++ b/isl_map.c @@ -1073,8 +1073,7 @@ static struct isl_basic_map *remove_duplicate_constraints( size = round_up(4 * (bmap->n_ineq+1) / 3 - 1); bits = ffs(size) - 1; - index = isl_alloc_array(ctx, isl_int **, size); - memset(index, 0, size * sizeof(isl_int **)); + index = isl_calloc_array(ctx, isl_int **, size); if (!index) return bmap; @@ -1303,8 +1302,7 @@ static struct isl_basic_map *remove_duplicate_divs( size = round_up(4 * bmap->n_div / 3 - 1); bits = ffs(size) - 1; - index = isl_alloc_array(ctx, int, size); - memset(index, 0, size * sizeof(int)); + index = isl_calloc_array(ctx, int, size); if (!index) return bmap; eq = isl_blk_alloc(ctx, 1+total); @@ -4320,8 +4318,7 @@ static struct isl_basic_set *remove_shifted_constraints( size = round_up(4 * (context->n_ineq+1) / 3 - 1); bits = ffs(size) - 1; - index = isl_alloc_array(ctx, isl_int **, size); - memset(index, 0, size * sizeof(isl_int **)); + index = isl_calloc_array(ctx, isl_int **, size); if (!index) return bset; -- 2.7.4