mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Fixed possible buffer overflow.
This commit is contained in:
parent
3b8b22493a
commit
93e8f4a85e
1 changed files with 4 additions and 10 deletions
|
@ -1421,6 +1421,7 @@ void lcPiecesLibrary::UpdateBuffers(lcContext* Context)
|
||||||
|
|
||||||
int VertexDataSize = 0;
|
int VertexDataSize = 0;
|
||||||
int IndexDataSize = 0;
|
int IndexDataSize = 0;
|
||||||
|
std::vector<lcMesh*> Meshes;
|
||||||
|
|
||||||
for (const auto& PieceIt : mPieces)
|
for (const auto& PieceIt : mPieces)
|
||||||
{
|
{
|
||||||
|
@ -1435,6 +1436,8 @@ void lcPiecesLibrary::UpdateBuffers(lcContext* Context)
|
||||||
|
|
||||||
VertexDataSize += Mesh->mVertexDataSize;
|
VertexDataSize += Mesh->mVertexDataSize;
|
||||||
IndexDataSize += Mesh->mIndexDataSize;
|
IndexDataSize += Mesh->mIndexDataSize;
|
||||||
|
|
||||||
|
Meshes.push_back(Mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
Context->DestroyVertexBuffer(mVertexBuffer);
|
Context->DestroyVertexBuffer(mVertexBuffer);
|
||||||
|
@ -1449,17 +1452,8 @@ void lcPiecesLibrary::UpdateBuffers(lcContext* Context)
|
||||||
VertexDataSize = 0;
|
VertexDataSize = 0;
|
||||||
IndexDataSize = 0;
|
IndexDataSize = 0;
|
||||||
|
|
||||||
for (const auto& PieceIt : mPieces)
|
for (lcMesh* Mesh : Meshes)
|
||||||
{
|
{
|
||||||
PieceInfo* Info = PieceIt.second;
|
|
||||||
lcMesh* Mesh = Info->IsPlaceholder() ? gPlaceholderMesh : Info->GetMesh();
|
|
||||||
|
|
||||||
if (!Mesh)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (Mesh->mVertexDataSize > 16 * 1024 * 1024 || Mesh->mIndexDataSize > 16 * 1024 * 1024)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
Mesh->mVertexCacheOffset = VertexDataSize;
|
Mesh->mVertexCacheOffset = VertexDataSize;
|
||||||
Mesh->mIndexCacheOffset = IndexDataSize;
|
Mesh->mIndexCacheOffset = IndexDataSize;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue