Skip to content

Commit

Permalink
Fix potential double free in HLodClass::Free (#1146)
Browse files Browse the repository at this point in the history
  • Loading branch information
xezon authored Aug 21, 2024
1 parent ba7056b commit 623d12e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/w3d/renderer/hlod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ HLodClass::HLodClass(const char *name, RenderObjClass **lods, int count) :
m_lodCount = count;
captainslog_assert(m_lodCount >= 1);

m_lod = new HLodClass::ModelArrayClass[m_lodCount];
m_lod = new ModelArrayClass[m_lodCount];
captainslog_assert(m_lod);

m_cost = new float[m_lodCount];
Expand Down Expand Up @@ -1742,6 +1742,9 @@ void HLodClass::Free()
m_lodCount = 0;
delete[] m_cost;
delete[] m_value;
m_lod = nullptr;
m_cost = nullptr;
m_value = nullptr;

for (int i = 0; i < m_additionalModels.Count(); i++) {
RenderObjClass *robj = m_additionalModels[i].m_model;
Expand Down

0 comments on commit 623d12e

Please sign in to comment.