=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/run.c,v retrieving revision 1.78 retrieving revision 1.79 diff -c -r1.78 -r1.79 *** src/usr.bin/awk/run.c 2023/09/20 16:49:13 1.78 --- src/usr.bin/awk/run.c 2023/10/06 22:29:24 1.79 *************** *** 1,4 **** ! /* $OpenBSD: run.c,v 1.78 2023/09/20 16:49:13 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved --- 1,4 ---- ! /* $OpenBSD: run.c,v 1.79 2023/10/06 22:29:24 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved *************** *** 2587,2592 **** --- 2587,2593 ---- fa *pfa; int mflag, tempstat, num; int bufsz = recsize; + int charlen = 0; if ((buf = (char *) malloc(bufsz)) == NULL) FATAL("out of memory in gsub"); *************** *** 2628,2634 **** if (*t == '\0') /* at end */ goto done; adjbuf(&buf, &bufsz, 2+pb-buf, recsize, &pb, "gsub"); ! *pb++ = *t++; if (pb > buf + bufsz) /* BUG: not sure of this test */ FATAL("gsub result0 %.30s too big; can't happen", buf); mflag = 0; --- 2629,2637 ---- if (*t == '\0') /* at end */ goto done; adjbuf(&buf, &bufsz, 2+pb-buf, recsize, &pb, "gsub"); ! 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;