Permalink
Browse files

C: Dynamic PVOP strings, fix threaded CopSTASHPV

OP_TRANS has no SvLEN, the op_pv is just freed.
NO special destruction for non-threaded CopSTASHPV
  • Loading branch information...
1 parent d839852 commit 1f87613a893432ad89ef29b2e0ad16e4ef7e519e Reini Urban committed Dec 17, 2012
Showing with 10 additions and 7 deletions.
  1. +10 −7 lib/B/C.pm
View
@@ -1355,11 +1355,14 @@ sub B::PVOP::save {
my $sym = objsym($op);
return $sym if defined $sym;
$loopsect->comment("$opsect_common, pv");
- $pvopsect->add( sprintf( "%s, %s", $op->_save_common, cstring( $op->pv ) ) );
+ # op_pv must be dynamic
+ $pvopsect->add( sprintf( "%s, NULL", $op->_save_common ) );
$pvopsect->debug( $op->name, $op->flagspv ) if $debug{flags};
my $ix = $pvopsect->index;
$init->add( sprintf( "pvop_list[$ix].op_ppaddr = %s;", $op->ppaddr ) )
unless $B::C::optimize_ppaddr;
+ my $pv = pack "a*", $op->pv;
+ $init->add( sprintf( "pvop_list[$ix].op_pv = savepvn(%s, %u);", cstring( $pv ), length($pv) ) );
savesym( $op, "(OP*)&pvop_list[$ix]" );
}
@@ -4961,12 +4964,12 @@ int my_perl_destruct( PerlInterpreter *my_perl ) {
} elsif ($s =~ /^cop_list/) {
if ($ITHREADS or !$MULTI) {
print " CopFILE_set(&$s, NULL);\n";
- if (!$ITHREADS) {
- if ($]<5.016 or $]>=5.017) {
- print " CopSTASHPV_set(&$s, NULL);\n"
- } else {
- print " CopSTASHPV_set(&$s, NULL, 0);\n";
- }
+ }
+ if (!$ITHREADS) {
+ if ($]<5.016 or $]>=5.017) {
+ print " CopSTASHPV_set(&$s, NULL);\n"
+ } else {
+ print " CopSTASHPV_set(&$s, NULL, 0);\n";
}
}
} elsif ($s ne 'ptr_undef') {

0 comments on commit 1f87613

Please sign in to comment.