zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Crash when exporting scalar without value and getsparam fails
Date: Fri, 9 Jan 2015 14:26:12 +0100	[thread overview]
Message-ID: <CAHYJk3TaSOSdKqaJez4nWW7C5zwP7OTdbKP4qD4z7bVJGAsvOg@mail.gmail.com> (raw)

2086                if (!(pm->node.flags & PM_UNSET) && !pm->env && !value)

30. returned_null: getsparam returns null (checked 46 out of 57
times). [show details]

CID 439066 (#1 of 1): Dereference null return value (NULL_RETURNS)31.
dereference: Dereferencing a pointer that might be null
getsparam(pname) when calling addenv. [show details]
2087                    addenv(pm, getsparam(pname));


The issue has this comment by Oliver on it, but I couldn't find any
thread about it with a cursory search, so I'm repeating it here;

Comment:

The line of code occurs when you export an existing scalar variable
without giving a new value. It isn't easy to find ways of making
getsparam to fail but I've found one which is enough to declare this a
bug:
 unset IFS
 export IFS
memory allocation failing, such as dupstring would also do the job.
Arguably these cases need fixing but the code highlighted here should
perhaps default to adding the variable to the environment with an
empty value.


and sure enough,
zsh: segmentation fault (core dumped)  zsh -fc 'unset IFS; export IFS'

Would the non-gnu equivalent of addenv(pm, getsparam(pname) ?: ""); do
the trick here? Or should it just return with an error? I guess if we
do the former, then the environment would get out of sync with the
internal parameter value.

-- 
Mikael Magnusson


             reply	other threads:[~2015-01-09 13:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09 13:26 Mikael Magnusson [this message]
2015-01-10  6:52 ` Bart Schaefer
2015-01-10  7:56   ` Mikael Magnusson
2015-01-10  8:09     ` Mikael Magnusson
2015-01-10 17:25       ` Bart Schaefer
2015-01-10 18:28         ` Bart Schaefer
2015-01-10 19:10           ` Mikael Magnusson
2015-01-10 20:04             ` Bart Schaefer
2015-01-10 20:28               ` Mikael Magnusson
2015-01-10 16:57     ` Bart Schaefer
2015-01-10 17:12       ` Mikael Magnusson

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=CAHYJk3TaSOSdKqaJez4nWW7C5zwP7OTdbKP4qD4z7bVJGAsvOg@mail.gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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).