-
Notifications
You must be signed in to change notification settings - Fork 89
[ZH] Fix RenderObjClass memory leaks in W3DPropBuffer #1319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ZH] Fix RenderObjClass memory leaks in W3DPropBuffer #1319
Conversation
@@ -119,7 +116,8 @@ W3DPropBuffer::W3DPropBuffer(void) | |||
{ | |||
memset(this, sizeof(W3DPropBuffer), 0); | |||
m_initialized = false; | |||
clearAllProps(); | |||
m_numProps = 0; | |||
m_numPropTypes = 0; | |||
m_light = NEW_REF( LightClass, (LightClass::DIRECTIONAL) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m_numProps
and m_numPropTypes
are already set to zero in clearAllProps()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They aren't initialised before this point, so since the loops were changed to use m_numPropTypes
and m_numProps
as their range, it could cause invalid behaviour as those variables have not been set yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced the call to clearAllProps()
because there is nothing clear.
Technically even m_numProps = 0, m_numPropTypes = 0
are useless because of the memset(this, sizeof(W3DPropBuffer), 0);
above, but nevermind that.
The constructor also sets m_initialized
twice :D Nevermind the mess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The memset
doesn't do anything here btw (0 parameter size).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, my original fix for this also initialised all of the available slots into a known state.
But looks like it's not that much of an issue with how the add and remove functions work overall.
Since you're refactoring the constructor of |
Is ok, can be separate change. |
This change fixes the RenderObjClass memory leaks in W3DPropBuffer. Is Zero Hour specific issue.
Tested by loading into Shell Map, into 1 Skirmish Map, and exit game. It would leak about 200 kb in this test.
Roughly the leaks marked with red are related to this