From a82b3a7d73e31af3357c4aac731719fbfb7b3d64 Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Mon, 4 Nov 2019 00:01:22 +0100 Subject: [PATCH] Model: Fix returning wrong attribute index when no token match --- Il2CppInspector/Il2CppModel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Il2CppInspector/Il2CppModel.cs b/Il2CppInspector/Il2CppModel.cs index 5ec1d1f..c02e830 100644 --- a/Il2CppInspector/Il2CppModel.cs +++ b/Il2CppInspector/Il2CppModel.cs @@ -117,7 +117,8 @@ namespace Il2CppInspector.Reflection var imageRange = image.customAttributeStart..(int)(image.customAttributeStart + image.customAttributeCount); // From v24.1 onwards, token was added to Il2CppCustomAttributeTypeRange and each Il2CppImageDefinition noted the CustomAttributeTypeRanges for the image - return Array.FindIndex(Package.AttributeTypeRanges[imageRange], x => x.token == token) + image.customAttributeStart; + var index = Array.FindIndex(Package.AttributeTypeRanges[imageRange], x => x.token == token); + return index == -1 ? -1 : index + image.customAttributeStart; } } } \ No newline at end of file