-
Notifications
You must be signed in to change notification settings - Fork 5
Copilot/fix array index out of bounds #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ | |
| import org.spongepowered.asm.mixin.injection.Redirect; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
|
||
| // Fixes "java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1" in onEntityRemove | ||
|
|
||
| @Mixin(SpawnReferenceSystems.MarkerAddRemoveSystem.class) | ||
| public abstract class MixinMarkerAddRemoveSystem { | ||
|
|
||
|
|
@@ -92,9 +94,9 @@ public abstract void onEntityRemove( | |
| InvalidatablePersistentRef[] refs = refixes$NPC_REFERENCES.get(); | ||
| refixes$NPC_REFERENCES.remove(); | ||
|
|
||
| if (refs == null) { | ||
| if (refs == null || refs.length == 0) { | ||
| refixes$LOGGER.atWarning().log( | ||
| "MarkerAddRemoveSystem#onEntityRemove(): Discarding due to null NPC references (%s)", | ||
| "MarkerAddRemoveSystem#onEntityRemove(): Discarding due to null or empty NPC references (%s)", | ||
| spawnMarkerComponent.getSpawnMarkerId()); | ||
| ci.cancel(); | ||
|
Comment on lines
+97
to
101
|
||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment claims the change fixes
Index 1 out of bounds for length 1, but the guard below only handlesnullor empty arrays. Please update the comment to match the actual condition handled (or adjust the guard so the comment is accurate).