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


           Summary: CheckParametersNullityInVisibleMethodsRule returns false
                    positive
           Product: Mono: Tools
           Version: SVN
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Gendarme
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
          Found By: ---


Gendarme complains about the following code.  However, it would be invalid to
call UnpackStringArray (ptr, null).  The compiler will prevent that from
occurring (error CS1510).

Attempts to recreate this issue with a simple assembly have failed, sorry. The
code is from Muine (available in bug 462925).

Gendarme should never complain about a parameter that is an out.

PS: typo on "caller is unk[n]own".


Code:
public static IntPtr UnpackStringArray (IntPtr p, out string [] array)
{
        IntPtr ret = p;

        int len;
        ret = Database.UnpackInt (ret, out len);

        array = new string [len];

        for (int i = 0; i < len; i++)
                ret = Database.UnpackString (ret, out array [i]);

        return ret;
}


Complaint:

37. CheckParametersNullityInVisibleMethodsRule

Problem: A visible method does not check its parameter(s) for null values.
* Severity: High, Confidence: Normal
* Target:   System.IntPtr
Muine.Database::UnpackStringArray(System.IntPtr,System.String[]&)
* Location: array
* Source:  
/home/tamara/My_Stuff/Computer/Programming/muine-gendarme-cleanup/muine.gendarme.pointer-length/src/Database.cs(≈345)

Solution: Since the caller is unkown you should always verify all of your
parameters to protect yourself.
More info available at:
http://www.mono-project.com/Gendarme.Rules.Correctness#CheckParametersNullityInVisibleMethodsRule


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to