From 0b4a11a8a4a213e2d89c4af8e53b75ea0761cc5b Mon Sep 17 00:00:00 2001 From: luboslenco Date: Mon, 3 Aug 2026 14:04:52 +0200 Subject: [PATCH] base: fix iron_random_get_max --- base/sources/iron_math.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/base/sources/iron_math.c b/base/sources/iron_math.c index 09f3870f..0b913f68 100644 --- a/base/sources/iron_math.c +++ b/base/sources/iron_math.c @@ -52,7 +52,8 @@ int64_t iron_random_get(void) { } int64_t iron_random_get_max(int64_t max) { - return iron_random_get() % (max + 1); + int64_t value = iron_random_get(); + return (value < -LLONG_MAX ? LLONG_MAX : llabs(value)) % (max + 1); } int64_t iron_random_get_in(int64_t min, int64_t max) {