* segv on typeset -A; a=(x y) builtin
@ 2017-12-22 22:17 Stephane Chazelas
0 siblings, 0 replies; only message in thread
From: Stephane Chazelas @ 2017-12-22 22:17 UTC (permalink / raw)
To: Zsh hackers list
$ typeset -A a=(1 2); a=(x y) eval typeset -p a
typeset -A a
a=( x y )
fine. But
$ unset a
$ typeset -A a; a=(x y) eval typeset -p a
zsh: segmentation fault zsh
same with typeset -A a; a=(); a=(x y) eval typeset -p a
same with other builtins or functions.
This:
diff --git a/Src/params.c b/Src/params.c
index 31ff044..de7730a 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -549,10 +549,13 @@ scancopyparams(HashNode hn, UNUSED(int flags))
HashTable
copyparamtable(HashTable ht, char *name)
{
- HashTable nht = newparamtable(ht->hsize, name);
- outtable = nht;
- scanhashtable(ht, 0, 0, 0, scancopyparams, 0);
- outtable = NULL;
+ HashTable nht = 0;
+ if (ht) {
+ nht = newparamtable(ht->hsize, name);
+ outtable = nht;
+ scanhashtable(ht, 0, 0, 0, scancopyparams, 0);
+ outtable = NULL;
+ }
return nht;
}
seens to fix it (as "ht" happens to be 0 here for empty hashes
which explains the segv) but I can't really tell if it's the
right/best fix.
--
Stephane
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-12-22 22:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-22 22:17 segv on typeset -A; a=(x y) builtin Stephane Chazelas
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).