I am using a tool (Fortify), which is detecting a vulnerability in the following block of code:
For Each member As Object In CType(members, IEnumerable)
Using x As DirectoryEntry = New DirectoryEntry(member)
Dim name As String = x.Name
If name <> deUser.Name Then
isGroupMember = False
Else
isGroupMember = True
Exit For
End If
End Using
Next member
It mentions that fails to release an LDAP resource (var X), due to the "Exit For".
As far as I know, statement "using" dispose the object although don't execute all the block code. Is that right? Or should it be done differently?
I Think is maybe a false-positive issue.