2007-07-17 Jb Evain <jbevain@novell.com>
authorJb Evain <jbevain@gmail.com>
Mon, 16 Jul 2007 22:14:30 +0000 (22:14 -0000)
committerJb Evain <jbevain@gmail.com>
Mon, 16 Jul 2007 22:14:30 +0000 (22:14 -0000)
* Mono.Cecil/AggressiveReflectionReader.cs:
Add some gards against zeroed tokens.

svn path=/trunk/mcs/; revision=82064

mcs/class/Mono.Cecil/ChangeLog
mcs/class/Mono.Cecil/Mono.Cecil/AggressiveReflectionReader.cs

index 4326172cb13e316090767904d0038a4ca87602a8..9cdeb5c19907e4b03006a134f0440a2ba1437186 100644 (file)
@@ -1,5 +1,8 @@
 2007-07-17  Jb Evain  <jbevain@novell.com>
 
+       * 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
index 199947e57c008fead306b8991f7a83f705802ca4..b3b16e494aebf3f9c61cc58f91a788dea30a3993 100644 (file)
@@ -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