aboutsummaryrefslogtreecommitdiff
path: root/src/ambigator.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-07-21 11:51:56 +0200
committerThomas White <taw@physics.org>2021-07-21 15:34:31 +0200
commit6d94d4115c254d344bbb927596a7141ef39fd298 (patch)
tree652d07c4d6a9521c9359aa13bbda27309f53e6f8 /src/ambigator.c
parent50cf52b0bc0baa683b9508568131a3f6281bf4ff (diff)
Add missing cleanup on error paths
Diffstat (limited to 'src/ambigator.c')
-rw-r--r--src/ambigator.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/ambigator.c b/src/ambigator.c
index 298002a7..1657bfb6 100644
--- a/src/ambigator.c
+++ b/src/ambigator.c
@@ -196,7 +196,7 @@ static struct flist *asymm_and_merge(RefList *in, const SymOpList *sym,
|| (f->s_reidx == NULL) || (f->i_reidx == NULL)
|| (f->group_reidx == NULL) || (f->group == NULL) ) {
ERROR("Failed to allocate flist\n");
- return NULL;
+ goto out;
}
f->n = 0;
@@ -218,7 +218,7 @@ static struct flist *asymm_and_merge(RefList *in, const SymOpList *sym,
if ( amb != NULL ) {
RefList *reidx = reflist_new();
- if ( reidx == NULL ) return NULL;
+ if ( reidx == NULL ) goto out;
for ( refl = first_refl(asym, &iter);
refl != NULL;
@@ -236,7 +236,8 @@ static struct flist *asymm_and_merge(RefList *in, const SymOpList *sym,
cr = add_refl(reidx, hra, kra, lra);
if ( cr == NULL ) {
ERROR("Failed to add reflection\n");
- return NULL;
+ reflist_free(reidx);
+ goto out;
}
copy_data(cr, refl);
}
@@ -260,6 +261,16 @@ static struct flist *asymm_and_merge(RefList *in, const SymOpList *sym,
reflist_free(asym);
return f;
+
+out:
+ free(f->s);
+ free(f->s_reidx);
+ free(f->i);
+ free(f->i_reidx);
+ free(f->group);
+ free(f->group_reidx);
+ free(f);
+ return NULL;
}
@@ -747,6 +758,7 @@ static void write_reindexed_stream(const char *infile, const char *outfile,
ofh = fopen(outfile, "w");
if ( ofh == NULL ) {
ERROR("Failed to open '%s'\n", outfile);
+ fclose(fh);
return;
}