isl_name_alloc: fix error handling
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 12 May 2010 09:29:06 +0000 (11:29 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 13 May 2010 16:53:54 +0000 (18:53 +0200)
isl_name.c

index 21b7ff7..8e902db 100644 (file)
@@ -19,12 +19,15 @@ struct isl_name *isl_name_alloc(struct isl_ctx *ctx, const char *s)
                return NULL;
        name = isl_alloc_type(ctx, struct isl_name);
        if (!name)
-               return NULL;
+               goto error;
 
        name->ref = 1;
        name->name = copy;
 
        return name;
+error:
+       free((char *)copy);
+       return NULL;
 }
 
 static int isl_name_has_name(const void *entry, const void *val)