Blob Blame History Raw
From 8aa649ab39c6113072f93d8065d846477ab297f1 Mon Sep 17 00:00:00 2001
From: Stephane Chazelas <stephane.chazelas@gmail.com>
Date: Fri, 22 Dec 2017 22:17:09 +0000
Subject: [PATCH] Avoid crash copying empty hash table.

Visible with typeset -p.

Upstream-commit: c2cc8b0fbefc9868fa83537f5b6d90fc1ec438dd
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 Src/params.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Src/params.c b/Src/params.c
index be8394b..25f34e8 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -492,10 +492,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;
 }
 
-- 
2.14.3