[Mono-bugs] [Bug 656005] New: cecil/light NRE in TypeReference.Resolve()

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Nov 25 13:56:59 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=656005

https://bugzilla.novell.com/show_bug.cgi?id=656005#c0


           Summary: cecil/light NRE in TypeReference.Resolve()
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Cecil
        AssignedTo: jbevain at novell.com
        ReportedBy: spouliot at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


TypeReference.Resolve can cause a NRE when a TypeSpecification is created with
a null TypeReference.

This occurs for both FunctionPointerType and PointerType (I hit both cases but
I did not look for others).

This can be duplicated by running Gendarme on
https://bugzilla.novell.com/attachment.cgi?id=353658 from bug
https://bugzilla.novell.com/show_bug.cgi?id=582823

This can be fixed with the following patch.

diff --git a/Mono.Cecil/TypeSpecification.cs b/Mono.Cecil/TypeSpecification.c
index d484eff..5469192 100644
--- a/Mono.Cecil/TypeSpecification.cs
+++ b/Mono.Cecil/TypeSpecification.cs
@@ -78,7 +78,9 @@ namespace Mono.Cecil {
                }

                public sealed override TypeReference GetElementType ()
-               {
+               {
+                       if (element_type == null)
+                               return this;
                        return element_type.GetElementType ();
                }
        }

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list