mirror of
https://github.com/isledecomp/isle-portable.git
synced 2025-09-22 11:31:57 -04:00
Fix UB in software renderer (#322)
* Fix UB in software renderer One cannot access elements of the vector that don't exist. `reserve` allocates memory, but doesn't add elements. `D3DRMVERTEX& dst = m_transformedVerts[i];` is UB and crashes on Windows debug build * Update renderer.cpp
This commit is contained in:
parent
0cfcc0fb21
commit
83205e2e4e
@ -710,10 +710,9 @@ void Direct3DRMSoftwareRenderer::SubmitDraw(
|
||||
|
||||
// Pre-transform all vertex positions and normals
|
||||
m_transformedVerts.clear();
|
||||
m_transformedVerts.reserve(mesh.vertices.size());
|
||||
for (size_t i = 0; i < mesh.vertices.size(); ++i) {
|
||||
const D3DRMVERTEX& src = mesh.vertices[i];
|
||||
D3DRMVERTEX& dst = m_transformedVerts[i];
|
||||
m_transformedVerts.resize(mesh.vertices.size());
|
||||
for (const auto& src : mesh.vertices) {
|
||||
D3DRMVERTEX& dst = m_transformedVerts.emplace_back();
|
||||
dst.position = TransformPoint(src.position, modelViewMatrix);
|
||||
dst.normal = src.normal;
|
||||
dst.texCoord = src.texCoord;
|
||||
|
Loading…
x
Reference in New Issue
Block a user