aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-07-12 11:04:34 +0200
committerAnton Khirnov <anton@khirnov.net>2020-07-12 11:04:34 +0200
commit017597067e33e3cb5938d49c83c7b60ed2ba773f (patch)
tree7e9df13f5bc887033308781d8fc488acbd174ec7
parentc90bddbfc94367fa26d806ea18b0c7314b870e52 (diff)
mg2d: avoid leaks in mg_dh_init()
-rw-r--r--mg2d.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/mg2d.c b/mg2d.c
index e7ae350..103f514 100644
--- a/mg2d.c
+++ b/mg2d.c
@@ -1044,6 +1044,7 @@ static int mg_dh_init(DomainHierarchy *dh, const DomainGeometry *root,
dg_tmp = realloc(dh->levels, (depth + 1) * sizeof(*dh->levels));
if (!dg_tmp) {
+ mg2di_dg_free(&cur_dg);
ret = -ENOMEM;
goto fail;
}
@@ -1051,6 +1052,7 @@ static int mg_dh_init(DomainHierarchy *dh, const DomainGeometry *root,
stepsizes_tmp = realloc(dh->stepsizes, (depth + 1) * sizeof(*dh->stepsizes));
if (!stepsizes_tmp) {
+ mg2di_dg_free(&cur_dg);
ret = -ENOMEM;
goto fail;
}
@@ -1067,6 +1069,7 @@ static int mg_dh_init(DomainHierarchy *dh, const DomainGeometry *root,
}
fail:
+ mg2di_dg_free(&next_dg);
if (ret < 0)
mg_dh_uninit(dh);
return ret;