From be17d02f6a71bc8194771265da649f642bed418b Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Tue, 17 Mar 2026 13:46:48 +0100 Subject: [PATCH] Fix for GHSA-rvv3-g6hj-g44x --- src/AutoMapper/Execution/TypeMapPlanBuilder.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AutoMapper/Execution/TypeMapPlanBuilder.cs b/src/AutoMapper/Execution/TypeMapPlanBuilder.cs index 6de44c6fc..9c3649207 100644 --- a/src/AutoMapper/Execution/TypeMapPlanBuilder.cs +++ b/src/AutoMapper/Execution/TypeMapPlanBuilder.cs @@ -1,6 +1,7 @@ namespace AutoMapper.Execution; public ref struct TypeMapPlanBuilder(IGlobalConfiguration configuration, TypeMap typeMap) { + const int DefaultMaxDepth = 64; static readonly MethodInfo MappingError = typeof(TypeMapPlanBuilder).GetStaticMethod(nameof(MemberMappingError)); static readonly MethodInfo IncTypeDepthInfo = typeof(ResolutionContext).GetInstanceMethod(nameof(ResolutionContext.IncrementTypeDepth)); static readonly MethodInfo DecTypeDepthInfo = typeof(ResolutionContext).GetInstanceMethod(nameof(ResolutionContext.DecrementTypeDepth)); @@ -106,6 +107,10 @@ private static void CheckForCycles(IGlobalConfiguration configuration, TypeMap t continue; } memberTypeMap.PreserveReferences = true; + if (memberTypeMap.MaxDepth == 0) + { + memberTypeMap.MaxDepth = DefaultMaxDepth; + } Trace(typeMap, memberTypeMap, memberMap); if (memberMap.Inline) {