isl_point_alloc: avoid potential memory leak on error path
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 19 Jun 2010 09:03:38 +0000 (11:03 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 19 Jun 2010 09:03:38 +0000 (11:03 +0200)
isl_point.c

index 9177c34..b7a7e10 100644 (file)
@@ -13,10 +13,6 @@ __isl_give isl_point *isl_point_alloc(__isl_take isl_dim *dim,
        if (!dim || !vec)
                goto error;
 
-       pnt = isl_alloc_type(dim->ctx, struct isl_point);
-       if (!pnt)
-               goto error;
-
        if (vec->size > 1 + isl_dim_total(dim)) {
                vec = isl_vec_cow(vec);
                if (!vec)
@@ -24,6 +20,10 @@ __isl_give isl_point *isl_point_alloc(__isl_take isl_dim *dim,
                vec->size = 1 + isl_dim_total(dim);
        }
 
+       pnt = isl_alloc_type(dim->ctx, struct isl_point);
+       if (!pnt)
+               goto error;
+
        pnt->ref = 1;
        pnt->dim = dim;
        pnt->vec = vec;