From ee5b49bb3307e70054299a00d6c3308996049ce2 Mon Sep 17 00:00:00 2001 From: Tim van der Molen <58601421+tbvdm@users.noreply.github.com> Date: Thu, 2 Jul 2020 20:22:15 +0200 Subject: [PATCH] Fix regression with changed SUBSEP in subscript (#86) Commit 0d8778bbbb415810bfd126694a38b6bf4b71e79c reintroduced a regression that was fixed in commit 97a4b7ed215ae6446d13fe0eab15b5b3ae4da7da. The length of SUBSEP needs to be rechecked after calling execute(), in case SUBSEP itself has been changed. Co-authored-by: Tim van der Molen --- run.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.c b/run.c index 9aff663..98787f1 100644 --- a/run.c +++ b/run.c @@ -472,7 +472,7 @@ makearraystring(Node *p, const char *func) { char *buf; int bufsz = recsize; - size_t blen, seplen; + size_t blen; if ((buf = malloc(bufsz)) == NULL) { FATAL("%s: out of memory", func); @@ -480,11 +480,11 @@ makearraystring(Node *p, const char *func) blen = 0; buf[blen] = '\0'; - seplen = strlen(getsval(subseploc)); for (; p; p = p->nnext) { Cell *x = execute(p); /* expr */ char *s = getsval(x); + size_t seplen = strlen(getsval(subseploc)); size_t nsub = p->nnext ? seplen : 0; size_t slen = strlen(s); size_t tlen = blen + slen + nsub;