From 8149ec3bd0119fb06e7bd4dbba208332d2ec6bf8 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 22 Apr 2024 15:18:18 +0200 Subject: [PATCH] Prevent adding self in compound tag --- pom.xml | 2 +- .../com/github/steveice10/opennbt/tag/builtin/CompoundTag.java | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a44b5a1..294fa94 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.viaversion nbt - 4.4.3 + 4.4.4 jar ViaNBT diff --git a/src/main/java/com/github/steveice10/opennbt/tag/builtin/CompoundTag.java b/src/main/java/com/github/steveice10/opennbt/tag/builtin/CompoundTag.java index 483b38b..a149874 100644 --- a/src/main/java/com/github/steveice10/opennbt/tag/builtin/CompoundTag.java +++ b/src/main/java/com/github/steveice10/opennbt/tag/builtin/CompoundTag.java @@ -330,6 +330,9 @@ public final class CompoundTag extends Tag implements Iterable T put(String tagName, T tag) { + if (tag == this) { + throw new IllegalArgumentException("Cannot add a tag to itself"); + } return (T) this.value.put(tagName, tag); }