qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends


From: Paul Brook
Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends
Date: Tue, 1 Dec 2009 14:21:45 +0000
User-agent: KMail/1.12.2 (Linux/2.6.31-1-amd64; KDE/4.3.2; x86_64; ; )

On Tuesday 01 December 2009, Glauber Costa wrote:
> On Tue, Dec 01, 2009 at 12:57:27PM +0000, Paul Brook wrote:
> > > You might want to have a 'static uint8_t zero_length_malloc[0]' and
> > > return that instead of the magic cookie '1'.  Makes the code more
> > > readable IMHO and you'll also have symbol in gdb when debugging qemu.
> >
> > Having multiple malloc return the same pointer sounds like a really bad
> > idea.
> 
> And why's that?
> 
> Keep in mind that *any* dereference over that address is a bug.

Dereferencing the address is a bug. However testing the addresses themselves 
for equality is valid. This is much the same reason I think returning NULL 
would be a bad idea.

Paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]