Copy scalar refs returned from @INC filters
This commit:
4464f08ea532be08ea7f0c44d0eb6e285a0c36fb is the first bad commit
commit
4464f08ea532be08ea7f0c44d0eb6e285a0c36fb
Author: Nicholas Clark <nick@ccl4.org>
Date: Fri Oct 23 16:54:10 2009 +0100
S_run_user_filter() can use the filter GV itself for the cache buffer.
This saves allocating an extra SV head and body.
caused this:
$ perl -e '@INC = sub { \$_ }; eval { require foo }; $a = $_;'
Bizarre copy of IO in sassign at -e line 1.
Well, passing the existing string to filter_add causes that string
*itself* to be upgraded to SVt_PVIO, which is clearly not a good thing
if the caller can still reference it. So we end up with $ bound to an
IO thingy.
And if the referent is a REGEXP, we get a crash during global destruc-
tion, or at least we did until the previous commit, which stopped
REGEXP->PVIO upgrades from being legal. (Clearly they don’t work.)
The easiest way to fix this is to copy the string into a new scalar,
which then gets upgraded to PVIO.