From f56c8875766f2de7ad6f69a6bd93685ac1ddd8dd Mon Sep 17 00:00:00 2001 From: Mitya Selivanov <0x7fffff@guattari.ru> Date: Sun, 7 Aug 2022 00:49:16 +0400 Subject: Add limit checks --- source/kit_test/run_tests.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/kit_test') diff --git a/source/kit_test/run_tests.c b/source/kit_test/run_tests.c index a4ebd12..c08f946 100644 --- a/source/kit_test/run_tests.c +++ b/source/kit_test/run_tests.c @@ -6,8 +6,20 @@ struct kit_tests_list kit_tests_list = { 0 }; static void report(int i, char const *file, int line, int ok) { + if (i >= KIT_TESTS_SIZE_LIMIT) { + printf("Kit Test error: Too many tests!"); + return; + } + int const n = kit_tests_list.tests[i].assertions++; + if (n >= KIT_TEST_ASSERTIONS_LIMIT) { + printf( + "Kit Test error: Too many test assertions for test \"%s\"!", + kit_tests_list.tests[i].test_name); + return; + } + kit_tests_list.tests[i].file[n] = file; kit_tests_list.tests[i].line[n] = line; kit_tests_list.tests[i].status[n] = ok; -- cgit v1.2.3