Model: Fix returning wrong attribute index when no token match

This commit is contained in:
Katy Coe
2019-11-04 00:01:22 +01:00
parent 7351e339f0
commit a82b3a7d73

View File

@@ -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;
}
}
}