zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: typeset: Fix leaving corrupted entries in paramtab
@ 2020-06-05 13:42 Mikael Magnusson
  2020-06-05 13:58 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2020-06-05 13:42 UTC (permalink / raw)
  To: zsh-workers

This appears to fix the problem in 45984, but I would appreciate someone
checking if it seems sane and/or complete.

---
 Src/builtin.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/Src/builtin.c b/Src/builtin.c
index 7a0c83e84d..010b2bd94f 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2480,12 +2480,16 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
 	    return NULL;
 	}
 	if (on & (PM_LEFT | PM_RIGHT_B | PM_RIGHT_Z)) {
-	    if (typeset_setwidth(cname, pm, ops, on, 0))
+	    if (typeset_setwidth(cname, pm, ops, on, 0)) {
+		unsetparam_pm(pm, 0, 1);
 		return NULL;
+	    }
 	}
 	if (on & (PM_INTEGER | PM_EFLOAT | PM_FFLOAT)) {
-	    if (typeset_setbase(cname, pm, ops, on, 0))
+	    if (typeset_setbase(cname, pm, ops, on, 0)) {
+		unsetparam_pm(pm, 0, 1);
 		return NULL;
+	    }
 	}
     } else {
 	if (idigit(*pname))
@@ -2503,8 +2507,10 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
 	 */
 	struct tieddata *tdp = (struct tieddata *)
 	    zalloc(sizeof(struct tieddata));
-	if (!tdp)
+	if (!tdp) {
+	    unsetparam_pm(pm, 0, 1);
 	    return NULL;
+	}
 	tdp->joinchar = joinchar;
 	tdp->arrptr = &altpm->u.arr;
 
-- 
2.15.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: typeset: Fix leaving corrupted entries in paramtab
  2020-06-05 13:42 PATCH: typeset: Fix leaving corrupted entries in paramtab Mikael Magnusson
@ 2020-06-05 13:58 ` Peter Stephenson
  2020-06-05 15:56   ` Mikael Magnusson
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2020-06-05 13:58 UTC (permalink / raw)
  To: zsh-workers

> On 05 June 2020 at 14:42 Mikael Magnusson <mikachu@gmail.com> wrote:
> This appears to fix the problem in 45984, but I would appreciate someone
> checking if it seems sane and/or complete.

Looks sane to me --- those are three cases where we've just created a new
parameter for some special purpose (which then failed), which isn't typical
in that function as it can operate on existing parameters too, so
additional action at those specific points is correct.

pws

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: PATCH: typeset: Fix leaving corrupted entries in paramtab
  2020-06-05 13:58 ` Peter Stephenson
@ 2020-06-05 15:56   ` Mikael Magnusson
  0 siblings, 0 replies; 3+ messages in thread
From: Mikael Magnusson @ 2020-06-05 15:56 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh workers

On Fri, Jun 5, 2020 at 3:59 PM Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
>
> > On 05 June 2020 at 14:42 Mikael Magnusson <mikachu@gmail.com> wrote:
> > This appears to fix the problem in 45984, but I would appreciate someone
> > checking if it seems sane and/or complete.
>
> Looks sane to me --- those are three cases where we've just created a new
> parameter for some special purpose (which then failed), which isn't typical
> in that function as it can operate on existing parameters too, so
> additional action at those specific points is correct.

Thanks for checking.

I thought about adding a test, but it'd only be possible to check for
these specific cases, and they'll only reoccur if someone removes the
code I added which seems hard to imagine. Similar bugs from other
flags wouldn't be found by the tests... so I opted not to add one.

-- 
Mikael Magnusson

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-05 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-05 13:42 PATCH: typeset: Fix leaving corrupted entries in paramtab Mikael Magnusson
2020-06-05 13:58 ` Peter Stephenson
2020-06-05 15:56   ` Mikael Magnusson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).