未验证 提交 32a25db6 编写于 作者: П Павел Харьков 提交者: GitHub

runtime: fix variable null check (#89920)

Fixed error when _hashtableContentsToEnumerate is null.
It appears always when using 'Length' property when variable is null.
Also reduced nesting.
上级 57105ef5
......@@ -689,27 +689,24 @@ internal Enumerator(LockFreeReaderHashtable<TKey, TValue> hashtable)
public bool MoveNext()
{
if (_sentinel != null)
if ((_sentinel != null) && (_hashtableContentsToEnumerate != null))
{
if ((_hashtableContentsToEnumerate != null) && (_index < _hashtableContentsToEnumerate.Length))
for (; _index < _hashtableContentsToEnumerate.Length; _index++)
{
for (; _index < _hashtableContentsToEnumerate.Length; _index++)
if ((_hashtableContentsToEnumerate[_index] != null) && (_hashtableContentsToEnumerate[_index] != _sentinel))
{
if ((_hashtableContentsToEnumerate[_index] != null) && (_hashtableContentsToEnumerate[_index] != _sentinel))
{
_current = _hashtableContentsToEnumerate[_index];
_index++;
return true;
}
_current = _hashtableContentsToEnumerate[_index];
_index++;
return true;
}
}
}
if ((_index == _hashtableContentsToEnumerate.Length) && _sentinel != null)
{
_current = _sentinel;
_index++;
return true;
if (_index == _hashtableContentsToEnumerate.Length)
{
_current = _sentinel;
_index++;
return true;
}
}
_current = default(TValue);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册