isl_basic_set_opt: avoid invalid access on error path
[platform/upstream/isl.git] / isl_space.c
index bd7d15c..e6f957c 100644 (file)
@@ -783,6 +783,8 @@ __isl_give isl_space *isl_space_extend(__isl_take isl_space *dim,
        isl_assert(dim->ctx, dim->n_out <= n_out, goto error);
 
        dim = isl_space_cow(dim);
+       if (!dim)
+               goto error;
 
        if (dim->ids) {
                ids = isl_calloc_array(dim->ctx, isl_id *,
@@ -1547,9 +1549,9 @@ static uint32_t isl_hash_dim(uint32_t hash, __isl_keep isl_space *dim)
        if (!dim)
                return hash;
 
-       hash = isl_hash_builtin(hash, dim->nparam);
-       hash = isl_hash_builtin(hash, dim->n_in);
-       hash = isl_hash_builtin(hash, dim->n_out);
+       isl_hash_byte(hash, dim->nparam % 256);
+       isl_hash_byte(hash, dim->n_in % 256);
+       isl_hash_byte(hash, dim->n_out % 256);
 
        for (i = 0; i < dim->nparam; ++i) {
                id = get_id(dim, isl_dim_param, i);