From def79f079d9e6beebe58e7ac091048d1ee4a42c4 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Sun, 12 May 2024 17:41:21 +0200 Subject: [PATCH] Prevent infinite recursion on cyclic brig redirect (#10705) Prevent infinite recursion when declaring a cyclic relation between command nodes via child nodes redirecting to an nth parent by marking a command node as unwrapped before unwrapping its children. --- patches/server/Brigadier-based-command-API.patch | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/patches/server/Brigadier-based-command-API.patch b/patches/server/Brigadier-based-command-API.patch index 9c92e5d3249..006d5b07dcd 100644 --- a/patches/server/Brigadier-based-command-API.patch +++ b/patches/server/Brigadier-based-command-API.patch @@ -401,6 +401,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + throw new IllegalArgumentException("Unknown command node passed. Don't know how to unwrap this."); + } + ++ // Store unwrapped node before unwrapping children to avoid infinite recursion in cyclic redirects. ++ converted.wrappedCached = pureNode; ++ pureNode.unwrappedCached = converted; ++ + /* + Add the children to the node, unwrapping each child in the process. + */ @@ -408,9 +412,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + converted.addChild(this.unwrapNode(child)); + } + -+ converted.wrappedCached = pureNode; -+ pureNode.unwrappedCached = converted; -+ + return converted; + } +