From d834ca4bfb0ef37d2dcaeb302a2b633a75193d1c Mon Sep 17 00:00:00 2001 From: "Diego F. Aranha" Date: Fri, 9 Jul 2021 10:45:12 +0200 Subject: [PATCH] Better place for exception throwing. --- src/rand/relic_rand_call.c | 4 +++- src/rand/relic_rand_core.c | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rand/relic_rand_call.c b/src/rand/relic_rand_call.c index a7e6e0491..f59236be6 100644 --- a/src/rand/relic_rand_call.c +++ b/src/rand/relic_rand_call.c @@ -77,7 +77,9 @@ void rand_bytes(uint8_t *buf, int size) { ctx_t *ctx = core_get(); ctx->rand_call(buf, size, ctx->rand_args); - rand_check(buf, size); + if (rand_check(buf, size) == RLC_ERR) { + RLC_THROW(ERR_NO_RAND); + } } void rand_seed(void (*callback)(uint8_t *, int, void *), void *args) { diff --git a/src/rand/relic_rand_core.c b/src/rand/relic_rand_core.c index fc025b940..10f8929f8 100644 --- a/src/rand/relic_rand_core.c +++ b/src/rand/relic_rand_core.c @@ -195,7 +195,6 @@ int rand_check(uint8_t *buf, int size) { } if (count > RAND_REP) { - RLC_THROW(ERR_NO_RAND); return RLC_ERR; } return RLC_OK;