Re: [AD] pack_ferror() - differences between platforms

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Monday 20 January 2003 8:12 am, you wrote:
> On Mon, Jan 20, 2003 at 12:01:52AM +0000, Ben Davis wrote:
> > It appears that malloc() is actually clearing the memory for me on Linux
>
> Yup - that's what it does on all *nix systems, AFAIK.
> This is a security issue - you wouldn't want to accidentally allow a
> program to allocate memory that happens to contain an unencrypted copy of
> the root password, now would you? ;)
> I thought it behaved the same in Windows, but it's been a while since I
> spend any real coding time in Windows.

Yeah, I found that the following:

   level = malloc(sizeof(*level));
   memset(level, 255, sizeof(*level));
   free(level);
   level = malloc(sizeof(*level));

did indeed change the outcome of my program, so I deduced what you've just 
told me. I would have posted, but I felt it was going too far off topic. I 
should have known better ;D

Incidentally I solved my problem by using DUMBFILEs. They're a nice layer of 
abstraction, on top of PACKFILEs or any other input stream, that will check 
the return values of all the functions; if EOF is ever returned, the DUMBFILE 
flags an error, which I can query later with dumbfile_error(). :)

Ben




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/