From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: jmk@plan9.bell-labs.com To: 9fans@cse.psu.edu Subject: Re: [9fans] thornbird (another xscreensaver hack) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Fri, 21 Jun 2002 19:02:06 -0400 Topicbox-Message-UUID: b5c474b6-eaca-11e9-9e20-41e7f4b1d025 On Fri Jun 21 18:45:41 EDT 2002, andrey@lanl.gov wrote: > > Reminder: malloc does not return zeroed storage. > > Either zero it on return or use mallocz. > > it's not my code -- i'm simply fixing the X-related stuff, adding > main(), drawing and that's all... haven't really debugged the actual > xscreensaver hack... > > unless malloc() behaves differently than the linux/unix ones i simply > didn't think there may be a problem -- it works there, why shouldn't > it here? "it works there, why shouldn't it here?" - Because it's different. The crash trace which someone posted was because Plan 9 malloc does not return zeroed memory and the code does a check to see whether pointers stored in that memory are NULL or not, and tries to free the non-NULL ones. I don't believe there is any requirement in the C standard (although I haven't checked) for the returned memory to be zeroed. A check of the 2 non-Plan 9 systems I have handy (Linux, Irix) show one will zero the memory and one won't.