about summary refs log tree commit diff
path: root/Src/params.c
diff options
context:
space:
mode:
authorStephane Chazelas <stephane.chazelas@gmail.com>2017-12-22 22:17:09 +0000
committerPeter Stephenson <pws@zsh.org>2018-01-04 17:12:13 +0000
commitc2cc8b0fbefc9868fa83537f5b6d90fc1ec438dd (patch)
tree7fde30b907d59b318cf4a291c056e0892ad51dda /Src/params.c
parent1e46f73b8e2e5e69dc40fd85ae83b88cccc1daf8 (diff)
downloadzsh-c2cc8b0fbefc9868fa83537f5b6d90fc1ec438dd.tar.gz
zsh-c2cc8b0fbefc9868fa83537f5b6d90fc1ec438dd.tar.xz
zsh-c2cc8b0fbefc9868fa83537f5b6d90fc1ec438dd.zip
Avoid crash copying empty hash table.
Visible with typeset -p.
Diffstat (limited to 'Src/params.c')
-rw-r--r--Src/params.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Src/params.c b/Src/params.c
index 31ff0445b..de7730ae7 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;
 }