summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2019-02-24 17:16:04 +0100
committerAnton Khirnov <anton@khirnov.net>2019-02-24 17:16:04 +0100
commitd11a14a27b59d91b64bcdfc7059f62fcec596001 (patch)
treeb7cc4b08248dc32fe78eced4b62643b2be8b7c0a
parentdc93a4e06a2c310def629bad665b4fe35cedcda0 (diff)
ell_grid_solve: do not read from outside of allocated boundary values
-rw-r--r--ell_grid_solve.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ell_grid_solve.c b/ell_grid_solve.c
index 9d50c82..1952f95 100644
--- a/ell_grid_solve.c
+++ b/ell_grid_solve.c
@@ -420,7 +420,7 @@ static int solve_exact(EGSContext *ctx)
continue;
for (ptrdiff_t bnd_layer = 1; bnd_layer < ctx->fd_stencil; bnd_layer++)
- for (ptrdiff_t bnd_idx = -(ptrdiff_t)ctx->fd_stencil; bnd_idx < (ptrdiff_t)(bnd_len[0] + ctx->fd_stencil); bnd_idx++) {
+ for (ptrdiff_t bnd_idx = -((ptrdiff_t)ctx->fd_stencil - 1); bnd_idx < (ptrdiff_t)(bnd_len[0] + ctx->fd_stencil - 1); bnd_idx++) {
e->rhs[mat_row_idx] -= bnd->val[bnd_layer * bnd->val_stride + bnd_idx] * dst[dir * bnd_layer * bnd_stride[1] + bnd_idx * bnd_stride[0]];
dst[dir * bnd_layer * bnd_stride[1] + bnd_idx * bnd_stride[0]] = 0.0;
}