isl_tab_pip.c: use_shifted: avoid invalid access on error path
[platform/upstream/isl.git] / isl_pw_templ.c
index 394571d..3993974 100644 (file)
@@ -538,9 +538,9 @@ static __isl_give PW *FN(PW,on_shared_domain_in)(__isl_take PW *pw1,
 
        n = pw1->n * pw2->n;
 #ifdef HAS_TYPE
-       res = FN(PW,alloc_size)(space, pw1->type, n);
+       res = FN(PW,alloc_size)(isl_space_copy(space), pw1->type, n);
 #else
-       res = FN(PW,alloc_size)(space, n);
+       res = FN(PW,alloc_size)(isl_space_copy(space), n);
 #endif
 
        for (i = 0; i < pw1->n; ++i) {
@@ -568,6 +568,7 @@ static __isl_give PW *FN(PW,on_shared_domain_in)(__isl_take PW *pw1,
                }
        }
 
+       isl_space_free(space);
        FN(PW,free)(pw1);
        FN(PW,free)(pw2);
        return res;
@@ -982,12 +983,14 @@ __isl_give PW *FN(PW,drop_dims)(__isl_take PW *pw,
        if (!pw->dim)
                goto error;
        for (i = 0; i < pw->n; ++i) {
-               pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
-               if (!pw->p[i].set)
-                       goto error;
                pw->p[i].FIELD = FN(EL,drop_dims)(pw->p[i].FIELD, type, first, n);
                if (!pw->p[i].FIELD)
                        goto error;
+               if (type == isl_dim_out)
+                       continue;
+               pw->p[i].set = isl_set_drop(pw->p[i].set, set_type, first, n);
+               if (!pw->p[i].set)
+                       goto error;
        }
 
        return pw;