From 86e3a8ae5122ccb8f6e6f3154568e3810776e02a Mon Sep 17 00:00:00 2001 From: Jb Evain Date: Mon, 16 Jul 2007 22:14:30 +0000 Subject: [PATCH] 2007-07-17 Jb Evain * Mono.Cecil/AggressiveReflectionReader.cs: Add some gards against zeroed tokens. svn path=/trunk/mcs/; revision=82064 --- mcs/class/Mono.Cecil/ChangeLog | 3 +++ .../Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/mcs/class/Mono.Cecil/ChangeLog b/mcs/class/Mono.Cecil/ChangeLog index 4326172cb13..9cdeb5c1990 100644 --- a/mcs/class/Mono.Cecil/ChangeLog +++ b/mcs/class/Mono.Cecil/ChangeLog @@ -1,5 +1,8 @@ 2007-07-17 Jb Evain + * Mono.Cecil/AggressiveReflectionReader.cs: + Add some gards against zeroed tokens. + * Mono.Cecil.Metadata/Utilities.cs: Return zero instead of throwing on invalid tags. Allow Cecil to read assemblies partially broken diff --git a/mcs/class/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs b/mcs/class/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs index 199947e57c0..b3b16e494ae 100644 --- a/mcs/class/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs +++ b/mcs/class/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs @@ -274,6 +274,9 @@ namespace Mono.Cecil { DeclSecurityRow dsRow = dsTable [i]; SecurityDeclaration dec = BuildSecurityDeclaration (dsRow); + if (dsRow.Parent.RID == 0) + continue; + IHasSecurity owner = null; switch (dsRow.Parent.TokenType) { case TokenType.Assembly : @@ -300,6 +303,10 @@ namespace Mono.Cecil { for (int i = 0; i < caTable.Rows.Count; i++) { CustomAttributeRow caRow = caTable [i]; MethodReference ctor; + + if (caRow.Type.RID == 0) + continue; + if (caRow.Type.TokenType == TokenType.Method) ctor = GetMethodDefAt (caRow.Type.RID); else -- 2.25.1