From 017597067e33e3cb5938d49c83c7b60ed2ba773f Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sun, 12 Jul 2020 11:04:34 +0200 Subject: mg2d: avoid leaks in mg_dh_init() --- mg2d.c | 3 +++ 1 file changed, 3 insertions(+) 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; -- cgit v1.2.3