mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 08:20:27 +00:00
Merge pull request #976 from rick2600/master
Fix #975 - null ptr dereference when a table is created with negative capacity
This commit is contained in:
commit
a9d4d2bfa3
@ -301,6 +301,7 @@ JANET_CORE_FN(cfun_table_new,
|
|||||||
"can be avoided. Returns the new table.") {
|
"can be avoided. Returns the new table.") {
|
||||||
janet_fixarity(argc, 1);
|
janet_fixarity(argc, 1);
|
||||||
int32_t cap = janet_getinteger(argv, 0);
|
int32_t cap = janet_getinteger(argv, 0);
|
||||||
|
if (cap < 0) janet_panic("expected positive integer");
|
||||||
return janet_wrap_table(janet_table(cap));
|
return janet_wrap_table(janet_table(cap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user