Re: Uninitialized data (or here we go again)


Subject: Re: Uninitialized data (or here we go again)
From: Thomas Fletcher (thomasf@qnx.com)
Date: Sat Nov 11 2000 - 16:10:19 CST


On Sat, 11 Nov 2000, Mike Nordell wrote:

> Taking AW through a test run using Purify, I'm sad to report that there are
> again more than a few places where uninitialized class data is read.
>
> This invokes "undefined behaviour", which in theory means it is allowed to
> do anything.
>
> Perhaps the worst example I've seen now is a call inside
> EV_Win32Toolbar::synthesize where the code uses a member
> "m_pWin32ToolbarIcons". This member is *never* initialized. In fact, it
> pointed south.
>
> Until I check in to this more, here are some replacement constructors for
> the first five classes Purify complained about. As for the
> m_pWin32ToolbarIcons I don't know what to do just yet (meaning I haven't yet
> looked into it). Sorry for not supplying patches, but they are at least
> simple drop-in replacements fro existing constructors.
>

Actually I noticed this quite a bit, both in platform specific code
and xp code. It would be a great first project for someone to go
through and make sure all of the member variables for a class are
always initialized to some value to start (even if it is just 0/NULL).

Thomas



This archive was generated by hypermail 2b25 : Sat Nov 11 2000 - 16:09:34 CST