Guard against invalid predefined assembly attributes
authorMarek Safar <marek.safar@gmail.com>
Mon, 24 Jan 2011 13:47:28 +0000 (13:47 +0000)
committerMarek Safar <marek.safar@gmail.com>
Mon, 24 Jan 2011 13:58:11 +0000 (13:58 +0000)
mcs/mcs/import.cs

index 2be579ccdec5d24c76796da08cba31b93fec3bd9..e3ada6de4f25359382ad5d09b654033892a91685 100644 (file)
@@ -1563,8 +1563,12 @@ namespace Mono.CSharp
                                importer.GetCustomAttributeTypeName (a, out ns, out name);
 
                                if (name == "CLSCompliantAttribute") {
-                                       if (ns == "System")
-                                               cls_compliant = (bool) a.ConstructorArguments[0].Value;
+                                       if (ns == "System") {
+                                               try {
+                                                       cls_compliant = (bool) a.ConstructorArguments[0].Value;
+                                               } catch {
+                                               }
+                                       }
                                        continue;
                                }
 
@@ -1572,7 +1576,13 @@ namespace Mono.CSharp
                                        if (ns != MetadataImporter.CompilerServicesNamespace)
                                                continue;
 
-                                       string s = a.ConstructorArguments[0].Value as string;
+                                       string s;
+                                       try {
+                                               s = a.ConstructorArguments[0].Value as string;
+                                       } catch {
+                                               s = null;
+                                       }
+
                                        if (s == null)
                                                continue;