zsh-workers
 help / color / mirror / code / Atom feed
* Crash when exporting scalar without value and getsparam fails
@ 2015-01-09 13:26 Mikael Magnusson
  2015-01-10  6:52 ` Bart Schaefer
  0 siblings, 1 reply; 11+ messages in thread
From: Mikael Magnusson @ 2015-01-09 13:26 UTC (permalink / raw)
  To: zsh workers

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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-01-10 20:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-09 13:26 Crash when exporting scalar without value and getsparam fails Mikael Magnusson
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

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).