-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
CScratchPad3D's CBaseCommand has a lot of children with heap allocated members like:
source-sdk-2013/src/public/scratchpad3d.h
Line 105 in 0759e2e
| class CCommand_Polygon : public CBaseCommand |
source-sdk-2013/src/public/scratchpad3d.h
Line 139 in 0759e2e
| class CCommand_Text : public CBaseCommand |
Problem is such CBaseCommand children are allocated in the heap and stored in a CUtlVector:
source-sdk-2013/src/public/scratchpad3d.h
Line 216 in 0759e2e
| CUtlVector<CBaseCommand*> m_Commands; |
which is deleted in CScratchPad3D::DeleteCommands():
source-sdk-2013/src/public/scratchpad3d.cpp
Line 205 in 0759e2e
| delete m_Commands[i]; |
But, as CBaseCommand missed virtual destructor, child destructors will not run and cause memory leaks:
source-sdk-2013/src/public/scratchpad3d.h
Line 54 in 0759e2e
| ~CBaseCommand() |
If you mark CBaseCommand destructor virtual, leaks are gone.