From 8058cee3a9ddafe823af6151121deb7e62b2413f Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 22 Jun 2025 18:02:38 +0800 Subject: [PATCH] Update typeinfo.c --- src/interpreter/typeinfo.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/interpreter/typeinfo.c b/src/interpreter/typeinfo.c index 49d2eeeb..d8a07756 100644 --- a/src/interpreter/typeinfo.c +++ b/src/interpreter/typeinfo.c @@ -45,6 +45,12 @@ const char* py_tpname(py_Type type) { } py_TypeInfo* pk_typeinfo(py_Type type) { +#ifndef NDEBUG + int length = pk_current_vm->types.length; + if(type < 0 || type >= length) { + c11__abort("type index %d is out of bounds [0, %d)", type, length); + } +#endif return c11__getitem(TypePointer, &pk_current_vm->types, type).ti; }