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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user