aboutsummaryrefslogtreecommitdiff
path: root/src/interp/linear/store.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interp/linear/store.c')
-rw-r--r--src/interp/linear/store.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/interp/linear/store.c b/src/interp/linear/store.c
index 6edffd9..904b969 100644
--- a/src/interp/linear/store.c
+++ b/src/interp/linear/store.c
@@ -18,7 +18,21 @@ enum nw_state nwp_linear_store(struct nw_interp *const i,
struct nw_sm_io *const io, const unsigned long offset)
{
const struct nw_interp_cfg *const cfg = &i->cfg;
- const enum nw_state n = nwp_mem_store(&cfg->linear, io, offset, cfg->user);
+ enum nw_state n;
+
+ if (nwp_linear_check(i, offset, io->n))
+ {
+ static const char *const exc = "out-of-bounds write access to "
+ "linear memory";
+
+#ifdef NW_LOG
+ nwp_log("%s, addr=%#lx, sz=%#lx\n", exc, offset, io->n);
+#endif
+ i->exception = exc;
+ return NW_FATAL;
+ }
+
+ n = nwp_mem_store(&cfg->linear, io, offset, cfg->user);
if (n == NW_FATAL)
{