Skip to content

Commit 94b99a7

Browse files
authored
[ZH] Fix RenderObjClass memory leaks in W3DPropBuffer (#1319)
1 parent f4a05b5 commit 94b99a7

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ void W3DPropBuffer::cull(CameraClass * camera)
101101
//=============================================================================
102102
W3DPropBuffer::~W3DPropBuffer(void)
103103
{
104-
Int i;
105-
for (i=0; i<MAX_TYPES; i++) {
106-
REF_PTR_RELEASE(m_propTypes[i].m_robj);
107-
}
104+
clearAllProps();
108105
REF_PTR_RELEASE(m_light);
109106
REF_PTR_RELEASE(m_propShroudMaterialPass);
110107
}
@@ -119,7 +116,8 @@ W3DPropBuffer::W3DPropBuffer(void)
119116
{
120117
memset(this, sizeof(W3DPropBuffer), 0);
121118
m_initialized = false;
122-
clearAllProps();
119+
m_numProps = 0;
120+
m_numPropTypes = 0;
123121
m_light = NEW_REF( LightClass, (LightClass::DIRECTIONAL) );
124122
m_propShroudMaterialPass = NEW_REF(W3DShroudMaterialPassClass,());
125123
m_initialized = true;
@@ -136,13 +134,16 @@ W3DPropBuffer::W3DPropBuffer(void)
136134
//=============================================================================
137135
void W3DPropBuffer::clearAllProps(void)
138136
{
139-
m_numProps=0;
140137
Int i;
141-
for (i=0; i<MAX_TYPES; i++) {
138+
for (i=0; i<m_numPropTypes; i++) {
142139
REF_PTR_RELEASE(m_propTypes[i].m_robj);
143140
m_propTypes[i].m_robjName.clear();
144141
}
142+
for (i=0; i<m_numProps; i++) {
143+
REF_PTR_RELEASE(m_props[i].m_robj);
144+
}
145145
m_numPropTypes = 0;
146+
m_numProps = 0;
146147
}
147148

148149
//=============================================================================

0 commit comments

Comments
 (0)