-/* $OpenBSD: b.c,v 1.35 2020/12/09 20:00:11 millert Exp $ */
+/* $OpenBSD: b.c,v 1.36 2021/03/02 20:41:42 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
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;
+ size += init_q + (atomlen+1)* (n_q_reps-init_q);
} else if (special_case == REPEAT_ZERO) {
size += 2; /* just a null ERE: () */
}
}
}
memcpy(&buf[j], reptok+reptoklen, suffix_length);
- if (special_case == REPEAT_ZERO) {
- buf[j+suffix_length] = '\0';
- } else {
- buf[size] = '\0';
- }
+ j += suffix_length;
+ buf[j] = '\0';
/* free old basestr */
if (firstbasestr != basestr) {
if (basestr)