aboutsummaryrefslogtreecommitdiff
path: root/src/op/memory/i32_load.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/op/memory/i32_load.c')
-rw-r--r--src/op/memory/i32_load.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/op/memory/i32_load.c b/src/op/memory/i32_load.c
index 04dbec7..ad5abe5 100644
--- a/src/op/memory/i32_load.c
+++ b/src/op/memory/i32_load.c
@@ -19,7 +19,7 @@ static int load(struct nw_interp *const i, const varuint32 flags,
const varuint32 offset)
{
enum {ALIGN = 2};
- int32_t value;
+ int32_t value_le;
if (flags != ALIGN)
{
@@ -28,12 +28,15 @@ static int load(struct nw_interp *const i, const varuint32 flags,
i->exception = "unaligned access";
return -1;
}
- else if (interp_heap_load(i, offset, &value, sizeof value))
+ else if (interp_heap_load(i, offset, &value_le, sizeof value_le))
{
LOG("%s: interp_heap_load failed\n", __func__);
return -1;
}
- else if (interp_stack_push(i, &value, sizeof value))
+
+ const int32_t value = ntohi32(value_le);
+
+ if (interp_stack_push(i, &value, sizeof value))
{
LOG("%s: interp_stack_push failed\n", __func__);
return -1;