Darrell Walisser
2017-02-15 17:38:20 UTC
valgrind found some uninitialized memory in ToolDock. I don't know if it
can cause a problem or not, but nonetheless it seems to have the potential
(uninitialized pointers). See diff below for one way to fix it.
Also I noticed in this class (ToolDock) it is derived from wxWidgetWrapper
but neither defines a virtual destructor. I can't imagine why that would be
a good idea. Browsing around I can find a few more instances of this - so I
guess there must be.
diff --git a/src/toolbars/ToolDock.h b/src/toolbars/ToolDock.h
index bda379e..cd74d45 100644
--- a/src/toolbars/ToolDock.h
+++ b/src/toolbars/ToolDock.h
@@ -63,8 +63,8 @@ public:
}
struct Position {
- ToolBar *rightOf {};
- ToolBar *below {};
+ ToolBar *rightOf {nullptr};
+ ToolBar *below {nullptr};
bool adopt {true};
bool valid {true};
@@ -325,7 +325,7 @@ public:
void Updated();
- int mTotalToolBarHeight;
+ int mTotalToolBarHeight = {0};
wxWindow *mParent;
ToolManager *mManager;
@@ -336,7 +336,7 @@ public:
// Configuration as modified by the constraint of the main window width
ToolBarConfiguration mWrappedConfiguration;
- ToolBar *mBars[ ToolBarCount ];
+ ToolBar *mBars[ ToolBarCount ]= {nullptr};
public:
can cause a problem or not, but nonetheless it seems to have the potential
(uninitialized pointers). See diff below for one way to fix it.
Also I noticed in this class (ToolDock) it is derived from wxWidgetWrapper
but neither defines a virtual destructor. I can't imagine why that would be
a good idea. Browsing around I can find a few more instances of this - so I
guess there must be.
diff --git a/src/toolbars/ToolDock.h b/src/toolbars/ToolDock.h
index bda379e..cd74d45 100644
--- a/src/toolbars/ToolDock.h
+++ b/src/toolbars/ToolDock.h
@@ -63,8 +63,8 @@ public:
}
struct Position {
- ToolBar *rightOf {};
- ToolBar *below {};
+ ToolBar *rightOf {nullptr};
+ ToolBar *below {nullptr};
bool adopt {true};
bool valid {true};
@@ -325,7 +325,7 @@ public:
void Updated();
- int mTotalToolBarHeight;
+ int mTotalToolBarHeight = {0};
wxWindow *mParent;
ToolManager *mManager;
@@ -336,7 +336,7 @@ public:
// Configuration as modified by the constraint of the main window width
ToolBarConfiguration mWrappedConfiguration;
- ToolBar *mBars[ ToolBarCount ];
+ ToolBar *mBars[ ToolBarCount ]= {nullptr};
public: