Skip to content

modules/gui/wxwidgets/dialogs/preferences_widgets.h:30: Base class ConfigControl doesn't have virtual destructor

In file modules/gui/wxwidgets/dialogs/preferences_widgets.h:30: Class ConfigControl which is inherited by class StringListConfigControl (and many other classes) does not have a virtual destructor.

StringListConfigControl releases memory in destructor:

StringListConfigControl::~StringListConfigControl()
{
    free( psz_default_value );
}

And it is used via an interface:

ConfigControl *p_control = NULL;
p_control = new StringListConfigControl( p_this, p_item, parent, false, l, line );

So if delete is called for the pointer, destructor of the implementing class ( StringListConfigControl in this case ) is not called and the memory is not released.

Very easy to fix. Change:

    ~ConfigControl();

Into:

    virtual ~ConfigControl();

This bug was found using cppcheck: http://cppcheck.wiki.sourceforge.net/

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information