From 8757f8df733d4c029d5d352c136988d1a3ea9281 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Mon, 19 Jun 2023 18:04:19 +0200 Subject: [PATCH] programs/sbf: c/float: work on stack values (#32192) Before this change the program was writing into the realloc region. Direct mapping is going to enforce permissions on the realloc region, and the program doesn't have permissions to write, so move to working on the stack to avoid access violation errors. --- programs/sbf/c/src/float/float.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/programs/sbf/c/src/float/float.c b/programs/sbf/c/src/float/float.c index 6caf0d66d4..d194a8ef65 100644 --- a/programs/sbf/c/src/float/float.c +++ b/programs/sbf/c/src/float/float.c @@ -15,10 +15,10 @@ extern uint64_t entrypoint(const uint8_t *input) { return ERROR_INVALID_ARGUMENT; } /* test float conversion to int compiles and works */ - uint32_t *data = (uint32_t *)(params.ka[0].data); - uint32_t new_data = *data + 1; - *data += 1.5; - sol_assert(*data == new_data); + uint32_t data = *(uint32_t *)(params.ka[0].data); + uint32_t new_data = data + 1; + data += 1.5; + sol_assert(data == new_data); /* test signed division works for FP values */ double value = (double)new_data + 1.0; @@ -26,7 +26,7 @@ extern uint64_t entrypoint(const uint8_t *input) { sol_assert(value < 0.0); /* test that standard math functions are available */ - value = *data + 1.0; + value = data + 1.0; sol_assert(log2(value) == 1.0); return SUCCESS;