From 7fda7709ff15ab4b4cdea57619365eb2798f15c4 Mon Sep 17 00:00:00 2001 From: rick2600 Date: Mon, 2 May 2022 12:57:47 -0300 Subject: [PATCH] fix negative count passed to cfun_array_new_filled --- src/core/array.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/array.c b/src/core/array.c index 834583ae..a93e8faa 100644 --- a/src/core/array.c +++ b/src/core/array.c @@ -137,6 +137,7 @@ JANET_CORE_FN(cfun_array_new_filled, "Creates a new array of `count` elements, all set to `value`, which defaults to nil. Returns the new array.") { janet_arity(argc, 1, 2); int32_t count = janet_getinteger(argv, 0); + if (count < 0) janet_panic("expected positive integer"); Janet x = (argc == 2) ? argv[1] : janet_wrap_nil(); JanetArray *array = janet_array(count); for (int32_t i = 0; i < count; i++) {