1
0
mirror of https://github.com/janet-lang/janet synced 2026-04-18 21:01:27 +00:00

Fix #1546 - large ranges.

Raise an error for very large ranges instead of internal assert.
This commit is contained in:
Calvin Rose
2025-01-20 09:02:22 -06:00
parent 2b49903c82
commit 06d581dde3
2 changed files with 3 additions and 1 deletions

View File

@@ -449,8 +449,9 @@ JANET_CORE_FN(janet_core_range,
}
count = (count > 0) ? count : 0;
int32_t int_count;
janet_assert(count >= 0, "bad range code");
if (count > (double) INT32_MAX) {
int_count = INT32_MAX;
janet_panicf("range is too large, %f elements", count);
} else {
int_count = (int32_t) ceil(count);
}