Fix #975 - null ptr dereference when a table is created with negative capacity

This commit is contained in:
rick2600 2022-05-05 02:11:43 -03:00
parent 0395a03b6b
commit 1ff521683f
1 changed files with 1 additions and 0 deletions

View File

@ -301,6 +301,7 @@ JANET_CORE_FN(cfun_table_new,
"can be avoided. Returns the new table.") {
janet_fixarity(argc, 1);
int32_t cap = janet_getinteger(argv, 0);
if (cap < 0) janet_panic("expected positive integer");
return janet_wrap_table(janet_table(cap));
}