Skip to content

[bug] CScratchPad3D's CBaseCommand heap allocated children leak due to a missed virtual destructor #745

@dimhotepus

Description

@dimhotepus

CScratchPad3D's CBaseCommand has a lot of children with heap allocated members like:

class CCommand_Polygon : public CBaseCommand

class CCommand_Text : public CBaseCommand

Problem is such CBaseCommand children are allocated in the heap and stored in a CUtlVector:

CUtlVector<CBaseCommand*> m_Commands;

which is deleted in CScratchPad3D::DeleteCommands():

delete m_Commands[i];

But, as CBaseCommand missed virtual destructor, child destructors will not run and cause memory leaks:

If you mark CBaseCommand destructor virtual, leaks are gone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions