使用关键字退出for循环

问题描述

我正在使用工具(Fortify),该工具正在以下代码块中检测漏洞:

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

它提到由于“ Exit For”而无法释放LDAP资源(变量X)。

据我所知,尽管没有执行所有的块代码,但语句“ using”会处理对象。 是对的吗? 还是应该以其他方式进行?

我认为这可能是一个假阳性问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)