summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2018-08-07 16:24:29 +0200
committerAnton Khirnov <anton@khirnov.net>2018-08-07 16:24:29 +0200
commit9ed2ae41d1bd3fb5a10d1db8a20f377ffdcbab8f (patch)
treec2d31d462cbcf70da1746a14ef04be04fb7e52dc
parent8e280f36631c8b4d8ccc9b142a9f70e485998efb (diff)
mg2d: fix boundary values allocation
-rw-r--r--mg2d.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/mg2d.c b/mg2d.c
index e019253..668e8ef 100644
--- a/mg2d.c
+++ b/mg2d.c
@@ -431,6 +431,9 @@ MG2DContext *mg2d_solver_alloc(size_t domain_size)
goto fail;
priv = ctx->priv;
+ if (SIZE_MAX / domain_size < domain_size)
+ goto fail;
+
priv->logger.log = log_callback;
priv->logger.opaque = ctx;
@@ -440,15 +443,12 @@ MG2DContext *mg2d_solver_alloc(size_t domain_size)
goto fail;
ret = posix_memalign((void**)&ctx->boundaries[i]->val, 32,
- sizeof(*ctx->boundaries[i]->val) * ctx->domain_size);
+ sizeof(*ctx->boundaries[i]->val) * domain_size);
if (ret != 0)
goto fail;
- ctx->boundaries[i]->val_len = ctx->domain_size;
+ ctx->boundaries[i]->val_len = domain_size;
}
- if (SIZE_MAX / domain_size < domain_size)
- goto fail;
-
ret = mg_levels_alloc(ctx, domain_size);
if (ret < 0)
goto fail;