From: Sven Verdoolaege Date: Thu, 4 Dec 2008 13:13:24 +0000 (+0100) Subject: isl_map.c: avoid potential NULL dereference X-Git-Tag: isl-0.01~349 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=325dce226c72cf48fe7343f481df065f3b1d766a;p=platform%2Fupstream%2Fisl.git isl_map.c: avoid potential NULL dereference --- 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;