regexec.c: avoid overflow in computing sum of lengths