From: Reini Urban Date: Wed, 2 Jul 2014 20:21:56 +0000 (-0500) Subject: Fix RT#96893 - do not change the string arg in XS; use a copy instead (problem under... X-Git-Tag: 0.06~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=24f50a799301562be9f7b22ce606fec869727e73;p=p5sagit%2FSub-Name.git Fix RT#96893 - do not change the string arg in XS; use a copy instead (problem under perlcc -O3) --- diff --git a/Changes b/Changes index e9f4b74..ff8b4e3 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,7 @@ +0.06 -- + * Do not change the string arg in XS, use copy instead. Fixes perlcc -O3 + RT#96893 (Reini Urban) + 0.05 -- Wed Sep 8 00:51 CEST 2010 * Stop using the padlist to refcount GVs. Instead use regular magic. This allows various modules, including B::Deparse, to safely peek into pads of diff --git a/Name.xs b/Name.xs index f6d7bc2..20c9b71 100644 --- a/Name.xs +++ b/Name.xs @@ -1,4 +1,5 @@ /* Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved. + * Copyright (C) 2014, cPanel Inc. All rights reserved. * This program is free software; you can redistribute it and/or modify * it under the same terms as Perl itself. */ @@ -30,7 +31,7 @@ subname(name, sub) CV *cv = NULL; GV *gv; HV *stash = CopSTASH(PL_curcop); - char *s, *end = NULL, saved; + char *s, *end = NULL; MAGIC *mg; PPCODE: if (!SvROK(sub) && SvGMAGICAL(sub)) @@ -57,13 +58,10 @@ subname(name, sub) end = s; } s--; - if (end) { - saved = *end; - *end = 0; - stash = GvHV(gv_fetchpv(name, TRUE, SVt_PVHV)); - *end = saved; - name = end; - } + if (end) { + stash = GvHV(gv_fetchpv(savepvn(name, end - name), TRUE, SVt_PVHV)); + name = end; + } gv = (GV *) newSV(0); gv_init(gv, stash, name, s - name, TRUE); diff --git a/README b/README index 11e62e6..92b76cc 100644 --- a/README +++ b/README @@ -39,6 +39,8 @@ DESCRIPTION AUTHOR Matthijs van Duin - Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved. This - program is free software; you can redistribute it and/or modify it under - the same terms as Perl itself. + Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved. + Copyright (C) 2014 cPanel Inc. All rights reserved. This program is free + software; you can redistribute it and/or modify it under the same terms + as Perl itself. + diff --git a/lib/Sub/Name.pm b/lib/Sub/Name.pm index 3172c74..f0b6127 100644 --- a/lib/Sub/Name.pm +++ b/lib/Sub/Name.pm @@ -34,6 +34,7 @@ can be very useful for debugging. Matthijs van Duin Copyright (C) 2004, 2008 Matthijs van Duin. All rights reserved. +Copyright (C) 2014 cPanel Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. diff --git a/t/RT96893_perlcc.t b/t/RT96893_perlcc.t new file mode 100644 index 0000000..c561f07 --- /dev/null +++ b/t/RT96893_perlcc.t @@ -0,0 +1,20 @@ +use strict; +use warnings; + +eval "use B::C;"; +if ($@) { + print "1..0 #SKIP B::C required for testing perlcc -O3\n"; + exit; +} else { + print "1..1\n"; +} + +my $f = "t/rt96893x.pl"; +open my $fh, ">", $f; END { unlink $f } +print $fh 'use Sub::Name; subname("main::bar", sub{42}); print "ok 1\n";'; +close $fh; + +system($^X, qw(-Mblib -S perlcc -O3 -UCarp -UConfig -r), $f); + +unlink "t/rt96893x", "t/rt96893x.exe"; +# vim: ft=perl