qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] fix qemu_malloc() error check for size==0


From: Jamie Lokier
Subject: Re: [Qemu-devel] [PATCH] fix qemu_malloc() error check for size==0
Date: Tue, 19 May 2009 21:37:04 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

malc wrote:
>   3) Test the returned value against NULL

Indeed, that makes malloc(0) a bad idea, and why GNU/Linux sensibly
makes it return a non-NULL pointer, to minimise unexpected behaviour
of programs.

>   4) Accidentally derefence it
> 
> And here one would get away with it on certain subset of systems.

That's not in the list of reliable things, though.

You mustn't accidentally dereference p[n] after calling p = malloc(n) either.

-- Jamie




reply via email to

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