From 1d2890961c3052ed202cf9d9445274da47a94a2c Mon Sep 17 00:00:00 2001 From: LukeFZ <17146677+LukeFZ@users.noreply.github.com> Date: Thu, 7 Dec 2023 20:52:06 +0100 Subject: [PATCH] Fix custom attribute parsing when a null array is used and when an assembly has no attributes --- Il2CppInspector.Common/Reflection/TypeModel.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector.Common/Reflection/TypeModel.cs b/Il2CppInspector.Common/Reflection/TypeModel.cs index fe71a12..35bb8db 100644 --- a/Il2CppInspector.Common/Reflection/TypeModel.cs +++ b/Il2CppInspector.Common/Reflection/TypeModel.cs @@ -270,6 +270,7 @@ namespace Il2CppInspector.Reflection var fqn = t switch { Il2CppTypeEnum.IL2CPP_TYPE_IL2CPP_TYPE_INDEX => "System.Type", + Il2CppTypeEnum.IL2CPP_TYPE_SZARRAY => "System.Array", _ => (int) t >= Il2CppConstants.FullNameTypeString.Count ? null : Il2CppConstants.FullNameTypeString[(int) t] @@ -322,7 +323,8 @@ namespace Il2CppInspector.Reflection // From v24.1 onwards, token was added to Il2CppCustomAttributeTypeRange and each Il2CppImageDefinition noted the CustomAttributeTypeRanges for the image // v29 uses this same system but with CustomAttributeDataRanges instead - if (!Package.AttributeIndicesByToken[asm.ImageDefinition.customAttributeStart].TryGetValue((uint)token, out var index)) + if (!Package.AttributeIndicesByToken.TryGetValue(asm.ImageDefinition.customAttributeStart, out var indices) + || !indices.TryGetValue((uint)token, out var index)) return -1; return index;