wxSelectionStore: Conditional jump or move depends on uninitialised value(s)

53 views
Skip to first unread message

Jan Engelhardt

unread,
Oct 28, 2013, 5:24:13 PM10/28/13
to wx-u...@googlegroups.com

Running valgrind over one of my programs I notice the following problem
(line numbers are wx 2.9.4).

==4680== Conditional jump or move depends on uninitialised value(s)
==4680== at 0x5A32C95: wxSelectionStore::SetItemCount(unsigned int) (selstore.cpp:221)
==4680== by 0x58D17CF: wxListMainWindow::SetItemCount(long) (listctrl.cpp:3389)
==4680== by 0x437445: MyGrid::show_stuff() (mainmenu.cpp:1138)

In selstore:221, we find

void wxSelectionStore::SetItemCount(unsigned count)
{
// forget about all items whose indices are now invalid if the size
// decreased
==> if ( count < m_count )

however, m_count was never initialized, because selstore.h just reads:

class WXDLLIMPEXP_CORE wxSelectionStore
{
public:
==> wxSelectionStore() : m_itemsSel(wxUIntCmp) { Init(); }

This is triggerable when you have a just-instantiated
wxLC_REPORT|wxLC_VIRTUAL wxListCtrl and then call SetItemCount on it.

From a source-only look, the problem seems to be still present in 3.0.0-rc2.

Vadim Zeitlin

unread,
Oct 28, 2013, 6:19:15 PM10/28/13
to wx-u...@googlegroups.com
On Mon, 28 Oct 2013 22:24:13 +0100 (CET) Jan Engelhardt wrote:

JE> Running valgrind over one of my programs I notice the following problem
JE> (line numbers are wx 2.9.4).
JE>
JE> ==4680== Conditional jump or move depends on uninitialised value(s)
JE> ==4680== at 0x5A32C95: wxSelectionStore::SetItemCount(unsigned int) (selstore.cpp:221)
JE> ==4680== by 0x58D17CF: wxListMainWindow::SetItemCount(long) (listctrl.cpp:3389)
JE> ==4680== by 0x437445: MyGrid::show_stuff() (mainmenu.cpp:1138)
JE>
JE> In selstore:221, we find
JE>
JE> void wxSelectionStore::SetItemCount(unsigned count)
JE> {
JE> // forget about all items whose indices are now invalid if the size
JE> // decreased
JE> ==> if ( count < m_count )
JE>
JE> however, m_count was never initialized, because selstore.h just reads:
JE>
JE> class WXDLLIMPEXP_CORE wxSelectionStore
JE> {
JE> public:
JE> ==> wxSelectionStore() : m_itemsSel(wxUIntCmp) { Init(); }
JE>
JE> This is triggerable when you have a just-instantiated
JE> wxLC_REPORT|wxLC_VIRTUAL wxListCtrl and then call SetItemCount on it.
JE>
JE> From a source-only look, the problem seems to be still present in
JE> 3.0.0-rc2.

This actually looks harmless, because whichever branch of the "if" flagged
above is taken doesn't matter for a freshly created wxSelectionStore, but
it's still better to fix this, of course, so I've just done it in r75094,
thanks for reporting this!
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Reply all
Reply to author
Forward
0 new messages