In the original code, there are chances to compare an iterator from m_CBsByName to m_StructuredBufferCBsByName.end(). It crashes if _ITERATOR_DEBUG_LEVEL is not 0. Fix it by comparing an iterator to the container it's from. (#3160)

Co-authored-by: Minmin Gong <mgong@microsoft.com>
This commit is contained in:
Minmin Gong 2021-01-29 14:31:52 -08:00 коммит произвёл GitHub
Родитель de63c27429
Коммит 65155d95bd
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -2323,11 +2323,19 @@ ID3D12ShaderReflectionConstantBuffer* DxilModuleReflection::_GetConstantBufferBy
return &g_InvalidSRConstantBuffer;
}
size_t index = m_CBs.size();
auto it = m_CBsByName.find(Name);
if (it == m_CBsByName.end())
if (it != m_CBsByName.end()) {
index = it->second;
} else {
it = m_StructuredBufferCBsByName.find(Name);
if (it != m_StructuredBufferCBsByName.end())
return m_CBs[it->second].get();
if (it != m_StructuredBufferCBsByName.end()) {
index = it->second;
}
}
if (index < m_CBs.size()) {
return m_CBs[index].get();
}
return &g_InvalidSRConstantBuffer;
}