summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2008-08-13 15:01:26 +0200
committerSven Verdoolaege <skimo@kotnet.org>2008-08-25 10:15:06 +0200
commitc46fd758a6b4982a79e707981b7d9e5fa8fe1f50 (patch)
treef236c70ea456581988b463cab754b7372635e5ec
parent0ab7e60a0e8e4069bf28b47027c0fec460dc4440 (diff)
downloadisl-c46fd758a6b4982a79e707981b7d9e5fa8fe1f50.tar.gz
isl-c46fd758a6b4982a79e707981b7d9e5fa8fe1f50.tar.bz2
isl-c46fd758a6b4982a79e707981b7d9e5fa8fe1f50.zip
add some missing tests for invalid input
-rw-r--r--isl_map.c26
-rw-r--r--isl_map_piplib.c3
2 files changed, 29 insertions, 0 deletions
diff --git a/isl_map.c b/isl_map.c
index 77aec4d2..84b9b99a 100644
--- a/isl_map.c
+++ b/isl_map.c
@@ -479,6 +479,9 @@ struct isl_basic_map *isl_basic_map_cow(struct isl_ctx *ctx,
static struct isl_set *isl_set_cow(struct isl_ctx *ctx, struct isl_set *set)
{
+ if (!set)
+ return NULL;
+
if (set->ref == 1)
return set;
set->ref--;
@@ -487,6 +490,9 @@ static struct isl_set *isl_set_cow(struct isl_ctx *ctx, struct isl_set *set)
struct isl_map *isl_map_cow(struct isl_ctx *ctx, struct isl_map *map)
{
+ if (!map)
+ return NULL;
+
if (map->ref == 1)
return map;
map->ref--;
@@ -1198,6 +1204,11 @@ static void dump(struct isl_basic_map *bmap, FILE *out, int indent)
void isl_basic_set_dump(struct isl_ctx *ctx, struct isl_basic_set *bset,
FILE *out, int indent)
{
+ if (!bset) {
+ fprintf(out, "null basic set\n");
+ return;
+ }
+
fprintf(out, "%*s", indent, "");
fprintf(out, "nparam: %d, dim: %d, extra: %d\n",
bset->nparam, bset->dim, bset->extra);
@@ -1207,6 +1218,11 @@ void isl_basic_set_dump(struct isl_ctx *ctx, struct isl_basic_set *bset,
void isl_basic_map_dump(struct isl_ctx *ctx, struct isl_basic_map *bmap,
FILE *out, int indent)
{
+ if (!bmap) {
+ fprintf(out, "null basic map\n");
+ return;
+ }
+
fprintf(out, "%*s", indent, "");
fprintf(out, "ref: %d, nparam: %d, in: %d, out: %d, extra: %d\n",
bmap->ref,
@@ -1344,6 +1360,11 @@ void isl_map_dump(struct isl_ctx *ctx, struct isl_map *map, FILE *out,
{
int i;
+ if (!map) {
+ fprintf(out, "null map\n");
+ return;
+ }
+
fprintf(out, "%*s", indent, "");
fprintf(out, "ref: %d, n: %d, nparam: %d, in: %d, out: %d\n",
map->ref, map->n, map->nparam, map->n_in, map->n_out);
@@ -1416,6 +1437,9 @@ struct isl_basic_map *isl_basic_map_intersect(
struct isl_ctx *ctx, struct isl_basic_map *bmap1,
struct isl_basic_map *bmap2)
{
+ if (!bmap1 || !bmap2)
+ goto error;
+
isl_assert(ctx, bmap1->nparam == bmap2->nparam, goto error);
isl_assert(ctx, bmap1->n_in == bmap2->n_in, goto error);
isl_assert(ctx, bmap1->n_out == bmap2->n_out, goto error);
@@ -2061,6 +2085,8 @@ error:
struct isl_map *isl_basic_map_compute_divs(struct isl_ctx *ctx,
struct isl_basic_map *bmap)
{
+ if (!bmap)
+ return NULL;
if (bmap->n_div == 0)
return isl_map_from_basic_map(ctx, bmap);
return isl_pip_basic_map_compute_divs(ctx, bmap);
diff --git a/isl_map_piplib.c b/isl_map_piplib.c
index 18328b02..8d21c992 100644
--- a/isl_map_piplib.c
+++ b/isl_map_piplib.c
@@ -383,6 +383,9 @@ static struct isl_map *extremum_on(struct isl_ctx *ctx,
struct isl_map *map;
PipMatrix *domain = NULL, *context = NULL;
+ if (!bmap || !dom)
+ goto error;
+
isl_assert(ctx, bmap->nparam == dom->nparam, goto error);
isl_assert(ctx, bmap->n_in == dom->dim, goto error);