I32 maxiters; ... strend = s + len; slen = RX_MATCH_UTF8(rx) ? utf8_length((U8*)s, (U8*)strend) : len; maxiters = 2 * slen + 10; /* We can match twice at each position, once with zero-length, second time with non-zero. */ ... if (iters++ > maxiters) DIE(aTHX_ "Substitution loop");