diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/Modules/db_gdbm.c | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index 269fa3932..66f3866cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-30 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 34439: Src/Modules/db_gdbm.c: unset parameter that's about to + be tied when necessary. + 2015-01-30 Peter Stephenson <p.stephenson@samsung.com> * 34435: Completion/Unix/Command/_sh, 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); |