=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/awk/b.c,v retrieving revision 1.35 retrieving revision 1.36 diff -c -r1.35 -r1.36 *** src/usr.bin/awk/b.c 2020/12/09 20:00:11 1.35 --- src/usr.bin/awk/b.c 2021/03/02 20:41:42 1.36 *************** *** 1,4 **** ! /* $OpenBSD: b.c,v 1.35 2020/12/09 20:00:11 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved --- 1,4 ---- ! /* $OpenBSD: b.c,v 1.36 2021/03/02 20:41:42 millert Exp $ */ /**************************************************************** Copyright (C) Lucent Technologies 1997 All Rights Reserved *************** *** 942,948 **** if (special_case == REPEAT_PLUS_APPENDED) { size++; /* for the final + */ } else if (special_case == REPEAT_WITH_Q) { ! size += init_q + (atomlen+1)* n_q_reps; } else if (special_case == REPEAT_ZERO) { size += 2; /* just a null ERE: () */ } --- 942,948 ---- if (special_case == REPEAT_PLUS_APPENDED) { size++; /* for the final + */ } else if (special_case == REPEAT_WITH_Q) { ! size += init_q + (atomlen+1)* (n_q_reps-init_q); } else if (special_case == REPEAT_ZERO) { size += 2; /* just a null ERE: () */ } *************** *** 971,981 **** } } memcpy(&buf[j], reptok+reptoklen, suffix_length); ! if (special_case == REPEAT_ZERO) { ! buf[j+suffix_length] = '\0'; ! } else { ! buf[size] = '\0'; ! } /* free old basestr */ if (firstbasestr != basestr) { if (basestr) --- 971,978 ---- } } memcpy(&buf[j], reptok+reptoklen, suffix_length); ! j += suffix_length; ! buf[j] = '\0'; /* free old basestr */ if (firstbasestr != basestr) { if (basestr)