Re: Return value of malloc(0)



Johannes Weiner <hnazfoo@xxxxxxxxxxxxxx> writes:

Hi,

On Wed, Jun 28, 2006 at 08:10:45PM +0200, Andre Albsmeier wrote:
"If you use malloc(0) and are crazy enough to access the 'allocated'
memory we give you a SIGSEV to show you how dumb you are :-)".

They should check the return value of malloc() in any case for
successful allocation.. shouldn't they?

The value returned from malloc(0) must not be dereferenced whatever it
was. It was 0x800, which doesn't count as "failure".

--
Matthias Andree
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Return value of malloc(0)
    ... memory we give you a SIGSEV to show you how dumb you are :-)". ... They should check the return value of malloc() in any case for ... successful allocation.. ...
    (freebsd-hackers)
  • Thank You -- Thomas J. Gritzan
    ... Thomas -- Your suggestion to malloc() out a block of memory was the ... Below are some details of my memory issues ... ... As a work around solution I guessed a ram disk would solve the ... persistence will frustrate the off topic police and give them a target ...
    (comp.lang.c)
  • Re: Simple question about headers and malloc!
    ... Therefore I am making all of its declarations ... memory (using malloc) and then exit back to main. ... allocation, I get data strored from the second allocation... ...
    (microsoft.public.vc.language)
  • Re: ten thousand small processes
    ... Stack needs to be executable for the current signal trampoline ... the use of malloc() that is causing your primary ... if there is any heap memory in use at all, no matter what you do, ... either directly, as a 4M page mapping (not used for user processes, ...
    (freebsd-performance)
  • Re: Review: My C FAQ Page
    ... the definition of memory leak is good but the information on ... this is not the most efficient way to allocate the 2-d array. ... You have ROW+1 calls to malloc. ... Allocate ROW pointers. ...
    (comp.lang.c)