From 727b493e2b782fca0f3933865faa9a0a6ab1a2c4 Mon Sep 17 00:00:00 2001 From: Wesley Schwengle Date: Mon, 17 Oct 2022 13:13:13 +0900 Subject: [PATCH] 50736: silence use-after-free warning (gcc-12.2) --- ChangeLog | 5 +++++ Src/Zle/compmatch.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 732721595..cb47acd1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2022-10-17 Jun-ichi Takimoto + + * Wesley Schwengle: 50736: Src/Zle/compmatch.c: silence + use-after-free waring (gcc-12.2) + 2022-09-29 Jun-ichi Takimoto * 50671: Util/ztst-syntax.vim: enable spell check in *.ztst diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index 56e5509a4..ddcecd589 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -2045,12 +2045,12 @@ join_strs(int la, char *sa, int lb, char *sb) zlelineasstring(line, mp->llen, 0, &convlen, NULL, 0); if (rr <= convlen) { - char *or = rs; + ptrdiff_t diff = rp - rs; int alloclen = (convlen > 20) ? convlen : 20; rs = realloc(rs, (rl += alloclen)); rr += alloclen; - rp += rs - or; + rp = rs + diff; } memcpy(rp, convstr, convlen); rp += convlen; @@ -2073,11 +2073,11 @@ join_strs(int la, char *sa, int lb, char *sb) } else { /* Same character, just take it. */ if (rr <= 1 /* HERE charlen */) { - char *or = rs; + ptrdiff_t diff = rp - rs; rs = realloc(rs, (rl += 20)); rr += 20; - rp += rs - or; + rp = rs + diff; } /* HERE: multibyte char */ *rp++ = *sa;