Fix crash with (??{undef *^R}) and (?{})
$ ./perl -Ilib -e '"" =~ /(??{undef *^R;""})(?{42})/'
Segmentation fault: 11
This started crashing in
4b22688e5c.
What happens is that the undef frees the scalar pointed to by oreplsv
in regtry, Then that scalar is reused for the regexp object created
from the return value of the ?? block. sv_setsv(oreplsv,...) ends up
trying to set the IV slot of a regexp, overwriting the engine field
(sv_setsv probably needs an assertion). Then later accesses crash
because r->engine is now a bad pointer.
(Though why it only started crashing in
4b22688e5c and not before I
have not figured out.)
The solution is for S_regtry to hang on to the SV with an extra refer-
ence count in case it gets freed.