From ce211bb8d11a030dbb9ad99f9590a378efdd4580 Mon Sep 17 00:00:00 2001
From: Peter Stephenson
Date: Fri, 30 Jan 2015 20:03:02 +0000
Subject: 34439: unset variable about to be tied
---
Src/Modules/db_gdbm.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
(limited to 'Src/Modules/db_gdbm.c')
diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index a6027deaf..9896bb536 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -77,8 +77,6 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
return 1;
}
- pmname = ztrdup(*args);
-
resource_name = OPT_ARG(ops, 'f');
dbf = gdbm_open(resource_name, 0, GDBM_WRCREAT | GDBM_SYNC, 0666, 0);
@@ -87,6 +85,21 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
return 1;
}
+ pmname = ztrdup(*args);
+
+ if ((tied_param = (Param)paramtab->getnode(paramtab, pmname)) &&
+ !(tied_param->node.flags & PM_UNSET)) {
+ /*
+ * Unset any existing parameter. Note there's no implicit
+ * "local" here, but if the existing parameter is local
+ * that will be reflected in the new one.
+ */
+ if (unsetparam_pm(tied_param, 0, 1)) {
+ zsfree(pmname);
+ gdbm_close(dbf);
+ return 1;
+ }
+ }
if (!(tied_param = createspecialhash(pmname, &getgdbmnode, &scangdbmkeys,
PM_REMOVABLE))) {
zwarnnam(nam, "cannot create the requested parameter %s", pmname);
--
cgit 1.4.1