From 1ff521683f1f61573a000d939eef94ca964f452c Mon Sep 17 00:00:00 2001 From: rick2600 Date: Thu, 5 May 2022 02:11:43 -0300 Subject: [PATCH] Fix #975 - null ptr dereference when a table is created with negative capacity --- src/core/table.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/table.c b/src/core/table.c index 18191a7a..c7235f64 100644 --- a/src/core/table.c +++ b/src/core/table.c @@ -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)); }