sed contains regexec calls that use REG_STARTEND with starts and ends
that are potentially not the start or end of the string being processed.
Adjust the string passed to regexec and the returned match offsets to
account for the difference in behavior when not using REG_STARTEND.
The do-while loop in substitute is the only use of REG_STARTEND with a non-zero start. Without the adjustments, doing multiple substitutions (e.g., echo 'a:b:c' | sed 's/:/ /g') would loop forever.
It's not perfect; it won't handle NUL bytes, and it won't handle word boundaries (also a non-standard extension) correctly. For example, echo one two three | sed 's/\<./1/g' with this change and the glibc regex functions will return "111 111 11111" instead of "1ne 1wo 1hree". I don't think it's possible to handle those cases without including the regex functions from FreeBSD's C library.
The difference in REG_STARTEND's newline behavior should be fine, at least. The do-while loop calls regexec with REG_NOTBOL, and the expression is never compiled with REG_NEWLINE, so regexec will correctly not match '^' before the substring.