about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <okiddle@yahoo.co.uk>2018-04-07 18:52:37 +0200
committerOliver Kiddle <okiddle@yahoo.co.uk>2018-04-07 18:52:37 +0200
commit8e6c1d8b474c6fcbe3da77a9cb2b1d31d65a6ca4 (patch)
tree967f00cdab2c095830d1a3862edfb56bf5d5a13c
parentd8753f47bb29d6bd5ca8d311b80fadca719982be (diff)
downloadzsh-8e6c1d8b474c6fcbe3da77a9cb2b1d31d65a6ca4.tar.gz
zsh-8e6c1d8b474c6fcbe3da77a9cb2b1d31d65a6ca4.tar.xz
zsh-8e6c1d8b474c6fcbe3da77a9cb2b1d31d65a6ca4.zip
42605: properly free the vi registers hash
-rw-r--r--ChangeLog3
-rw-r--r--Src/Modules/mapfile.c3
-rw-r--r--Src/Zle/complete.c3
-rw-r--r--Src/Zle/zle_params.c14
4 files changed, 19 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 0ced3c876..ed5bf108a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2018-04-07  Oliver Kiddle  <okiddle@yahoo.co.uk>
 
+	* 42605: Src/Modules/mapfile.c, Src/Zle/complete.c,
+	Src/Zle/zle_params.c: properly free the vi registers hash
+
 	* 42601: Src/builtin.c: tidy up code for set -A/+A to not
 	increment a NULL pointer and to be more efficient
 
diff --git a/Src/Modules/mapfile.c b/Src/Modules/mapfile.c
index 7a903418f..dd86fb596 100644
--- a/Src/Modules/mapfile.c
+++ b/Src/Modules/mapfile.c
@@ -158,7 +158,8 @@ setpmmapfiles(Param pm, HashTable ht)
 
 		setpmmapfile(v.pm, ztrdup(getstrvalue(&v)));
 	    }
-    deleteparamtable(ht);
+    if (ht != pm->u.hash)
+	deleteparamtable(ht);
 }
 
 /**/
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 313dcb92f..1dc2b01c2 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -1325,7 +1325,8 @@ set_compstate(UNUSED(Param pm), HashTable ht)
 
 		    break;
 		}
-    deleteparamtable(ht);
+    if (ht != pm->u.hash)
+	deleteparamtable(ht);
 }
 
 /**/
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 0a922d2d6..f3112165a 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -124,7 +124,7 @@ static const struct gsu_array killring_gsu =
 static const struct gsu_scalar register_gsu =
 { strgetfn, set_register, unset_register };
 static const struct gsu_hash registers_gsu =
-{ hashgetfn, set_registers, zleunsetfn };
+{ hashgetfn, set_registers, unset_registers };
 
 /* implementation is in zle_refresh.c */
 static const struct gsu_array region_highlight_gsu =
@@ -837,7 +837,17 @@ set_registers(UNUSED(Param pm), HashTable ht)
 
 	    set_register(v.pm, getstrvalue(&v));
         }
-    deleteparamtable(ht);
+    if (ht != pm->u.hash)
+	deleteparamtable(ht);
+}
+
+/**/
+static void
+unset_registers(Param pm, int exp)
+{
+    stdunsetfn(pm, exp);
+    deletehashtable(pm->u.hash);
+    pm->u.hash = NULL;
 }
 
 static void