ref: 53a653bb2889564a8fe053761dbf41baacfbe92b
parent: 89d12d31ee81163f1810018c3177971ab6b862ce
author: ozan yigit <ozan.yigit@gmail.com>
date: Wed Sep 27 19:21:48 EDT 2023
arnold's fix for gsub null match bug with unicode chars
--- a/run.c
+++ b/run.c
@@ -2466,6 +2466,7 @@
fa *pfa;
int mflag, tempstat, num;
int bufsz = recsize;
+ int charlen = 0;
if ((buf = (char *) malloc(bufsz)) == NULL)
FATAL("out of memory in gsub");@@ -2507,7 +2508,9 @@
if (*t == '\0') /* at end */
goto done;
adjbuf(&buf, &bufsz, 2+pb-buf, recsize, &pb, "gsub");
- *pb++ = *t++;
+ charlen = u8_nextlen(t);
+ while (charlen-- > 0)
+ *pb++ = *t++;
if (pb > buf + bufsz) /* BUG: not sure of this test */
FATAL("gsub result0 %.30s too big; can't happen", buf);mflag = 0;
--
⑨