isl_polynomial.c: use flex array member to avoid array out of bounds warning
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 25 May 2011 10:58:40 +0000 (12:58 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 25 May 2011 12:09:01 +0000 (14:09 +0200)
The p field in struct isl_upoly_rec is meant to be a flexible array member,
but this was only introduced in C99 and so we were using a slightly
different construct.  However, we already assume C99 (in particular,
designated initializers) in the rest of the code and recent versions
of clang complain about possible array out of bounds accesses when
we don't use a flexible array member.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_polynomial.c
isl_polynomial_private.h

index ba9179c..2092d8b 100644 (file)
@@ -326,7 +326,7 @@ __isl_give struct isl_upoly_rec *isl_upoly_alloc_rec(struct isl_ctx *ctx,
        isl_assert(ctx, size >= 0, return NULL);
        rec = isl_calloc(ctx, struct isl_upoly_rec,
                        sizeof(struct isl_upoly_rec) +
-                       (size - 1) * sizeof(struct isl_upoly *));
+                       size * sizeof(struct isl_upoly *));
        if (!rec)
                return NULL;
 
index 74f7144..8f6a7b7 100644 (file)
@@ -24,7 +24,7 @@ struct isl_upoly_rec {
        int n;
 
        size_t size;
-       struct isl_upoly *p[1];
+       struct isl_upoly *p[];
 };
 
 struct isl_qpolynomial {