From 1c9681916f05e6736848a2057581ff19603c27b2 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Wed, 28 Aug 2024 20:12:02 +0200 Subject: [PATCH] Fix iterator leak. Fix #168 --- src/main/java/dev/tr7zw/entityculling/CullTask.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/tr7zw/entityculling/CullTask.java b/src/main/java/dev/tr7zw/entityculling/CullTask.java index 2f67c11..7482994 100644 --- a/src/main/java/dev/tr7zw/entityculling/CullTask.java +++ b/src/main/java/dev/tr7zw/entityculling/CullTask.java @@ -92,7 +92,11 @@ private void cullEntities(Vec3 cameraMC, Vec3d camera) { // less // overhead probably than trying to sync stuff up for no really good reason } - if (entity == null || !(entity instanceof Cullable)) { + if (entity == null) { + // assume the iterator is broken, cancel the loop https://github.com/tr7zw/EntityCulling/issues/168 + break; + } + if (!(entity instanceof Cullable)) { continue; // Not sure how this could happen outside from mixin screwing up the inject into // Entity } @@ -145,6 +149,10 @@ private void cullBlockEntities(Vec3 cameraMC, Vec3d camera) { // less // overhead probably than trying to sync stuff up for no really good reason } + if (entry == null) { + // assume the iterator is broken, cancel the loop https://github.com/tr7zw/EntityCulling/issues/168 + break; + } if (blockEntityWhitelist.contains(entry.getValue().getType())) { continue; }