static bool
S_already_defined(pTHX_ CV *const cv, OP * const block, OP * const o,
- PADNAME * const name, SV ** const const_svp)
+ PADNAME * const name, SV ** const const_svp,
+ GV * const gv)
{
assert (cv);
assert (o || name);
#endif
{
/* (PL_madskills unset in used file.) */
+ if (gv) GvCV_set(gv,NULL);
SvREFCNT_dec(cv);
}
return TRUE;
cv_ckproto_len_flags(cv, (GV *)name, ps, ps_len, ps_utf8);
/* already defined? */
if (exists) {
- if (S_already_defined(aTHX_ cv, block, NULL, name, &const_sv))
+ if (S_already_defined(aTHX_ cv,block,NULL,name,&const_sv,NULL))
cv = NULL;
else {
if (attrs) goto attrs;
cv_ckproto_len_flags(cv, gv, ps, ps_len, ps_utf8);
/* already defined (or promised)? */
if (exists || GvASSUMECV(gv)) {
- if (S_already_defined(aTHX_ cv, block, o, NULL, &const_sv))
+ if (S_already_defined(aTHX_ cv, block, o, NULL, &const_sv, gv))
cv = NULL;
else {
if (attrs) goto attrs;
require './test.pl';
}
-plan( tests => 32 );
+plan( tests => 33 );
sub empty_sub {}
is $str[1], $str[0],
'XSUB clobbering sub whose DESTROY assigns to the glob';
}
+{
+ no warnings 'redefine';
+ sub foo {}
+ bless \&foo, 'newATTRSUBbug';
+ sub newATTRSUBbug::DESTROY {
+ my $str1 = "$_[0]";
+ *foo = sub{}; # GvSV had no refcount, so this freed it
+ my $str2 = "$_[0]"; # used to be UNKNOWN(0x7fdda29310e0)
+ @str = ($str1, $str2);
+ }
+ splice @str;
+ eval "sub foo{}";
+ is $str[1], $str[0],
+ 'Pure-Perl sub clobbering sub whose DESTROY assigns to the glob';
+}