diff --git a/src/pc/lua/utils/smlua_obj_utils.c b/src/pc/lua/utils/smlua_obj_utils.c index afa70ffc1..3f9e63db3 100644 --- a/src/pc/lua/utils/smlua_obj_utils.c +++ b/src/pc/lua/utils/smlua_obj_utils.c @@ -112,9 +112,11 @@ Trajectory* get_trajectory(const char* name) { struct Object *obj_get_first(enum ObjectList objList) { if (gObjectLists && objList >= 0 && objList < NUM_OBJ_LISTS) { + u32 sanityDepth = 0; struct Object *head = (struct Object *) &gObjectLists[objList]; struct Object *obj = (struct Object *) head->header.next; while (obj != head) { + if (++sanityDepth > 10000) { break; } if (obj->activeFlags != ACTIVE_FLAG_DEACTIVATED) { return obj; } @@ -126,9 +128,11 @@ struct Object *obj_get_first(enum ObjectList objList) { static struct Object *obj_get_next_internal(struct Object *o, enum ObjectList objList) { if (gObjectLists && o) { + u32 sanityDepth = 0; struct Object *head = (struct Object *) &gObjectLists[objList]; struct Object *next = (struct Object *) o->header.next; while (next != head) { + if (++sanityDepth > 10000) { break; } if (next->activeFlags != ACTIVE_FLAG_DEACTIVATED) { return next; }