vec(): downgrade before accessing string buffer
This code:
#!perl -l
$x = substr "\x{100}\xff\xfe", 1;
print vec($x, 0, 8);
print vec($x, 0, 8);
In 5.18 and earlier prints
255
255
With blead it prints:
195
255
This is due to the fact that it does SvPV() first to get the string buffer,
then calls sv_utf8_downgrade(). With COW, the PVX of the SV may no longer
equal the value earlier returned by SvPV(), but vec() continues to use the
old pointer. This bug has always been present, but COW made it more
noticeable.
The fix is to just redo the SvPV() after a downgrade.