From d6efedb34b430ee004d9bf400c7eed2a140a4714 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 9 Jan 2025 22:17:55 -0300 Subject: Fix integer overflow in multiple scripts, but most notably, Ofelia. It was harmless, in the end? --- npc/functions/bitwise.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/npc/functions/bitwise.txt b/npc/functions/bitwise.txt index 023606629..eadfb30ce 100644 --- a/npc/functions/bitwise.txt +++ b/npc/functions/bitwise.txt @@ -56,6 +56,10 @@ function script bitmask_count { // Loop only as needed while (.@s < .@n) { + // Safeguard (2,147,483,647 is INT_MAX) + if (.@m >= 31) + break; + // Actual calculation .@s=2**.@m; if (.@n & .@s) .@p++; -- cgit v1.2.3-70-g09d2