Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: and query for malloc(0).



Geoff Wing wrote:
> On Saturday 2007-04-28 07:36 +1000, Peter Stephenson output:
> :Playing with POSIX regexes, I found some errors coming from zsh's memory
> :allocation with debugging on.  These turned out to resolve to some
> :malloc()s and free()s for zero length and the following oddity in
> :malloc():
> :    /* some systems want malloc to return the highest valid address plus one
> :       if it is called with an argument of zero */
> :    if (!size)
> :	return (MALLOC_RET_T) m_high;
>...
> Given the above, I guess the patch is a reasonable fix.

Thanks, I think I'll commit it and see what happens; under most
circumstances that will be very little.

> We are not actually calling malloc(0) in-house, are we?

No, that should be trapped up above in zalloc(), etc.  I've only seen
the problem when linked with a C library function that's calling
malloc(0).

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview



Messages sorted by: Reverse Date, Date, Thread, Author