zsh-workers
 help / color / mirror / code / Atom feed
From: Geoff Wing <gcw@zsh.org>
To: Zsh Hackers <zsh-workers@sunsite.dk>
Subject: Re: PATCH: and query for malloc(0).
Date: Mon, 30 Apr 2007 13:29:48 +1000	[thread overview]
Message-ID: <20070430032948.GA2612@primenet.com.au> (raw)
In-Reply-To: <200704272135.l3RLZE1d005051@pwslaptop.csr.com>

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;

This appeared in zsh 2.5.  I don't know the origin.

It's a bit weird as different systems will do conflicting things with it.

NetBSD returns NULL

An older Solaris man page says for malloc(): "a unique pointer to the arena
 is returned"; and for bsdmalloc(): "a non-NULL pointer. ... These pointers
 should not be dereferenced."

SUS says: "If size is 0, either a null pointer or a unique pointer that can
 be successfully passed to free() shall be returned."

Given the above, I guess the patch is a reasonable fix.

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

Regards,
Geoff


  reply	other threads:[~2007-04-30  3:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-27 21:35 Peter Stephenson
2007-04-30  3:29 ` Geoff Wing [this message]
2007-04-30  9:22   ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070430032948.GA2612@primenet.com.au \
    --to=gcw@zsh.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).