In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/8af710ebc7fee929ae47793d5a0cce5362af52db?hp=133acf7b389614db651d1ed570d4a0ca0c747999>
- Log ----------------------------------------------------------------- commit 8af710ebc7fee929ae47793d5a0cce5362af52db Author: Tony Cook <t...@develop-help.com> Date: Thu Jun 17 18:58:04 2010 +1000 RT #75812: apply get magic before checking flags, PVX The code was checking flags with applying any get magic, so when a match was doing putting a numeric string into $1, none of the flags checked were set, so producing the "non-numeric process ID" error. ----------------------------------------------------------------------- Summary of changes: doio.c | 9 ++++++--- t/op/kill0.t | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doio.c b/doio.c index 98861af..06f2d3d 100644 --- a/doio.c +++ b/doio.c @@ -1721,9 +1721,10 @@ nothing in the core. while (++mark <= sp) { I32 proc; register unsigned long int __vmssts; + SvGETMAGIC(*mark); if (!(SvIOK(*mark) || SvNOK(*mark) || looks_like_number(*mark))) Perl_croak(aTHX_ "Can't kill a non-numeric process ID"); - proc = SvIV(*mark); + proc = SvIV_nomg(*mark); APPLY_TAINT_PROPER(); if (!((__vmssts = sys$delprc(&proc,0)) & 1)) { tot--; @@ -1748,9 +1749,10 @@ nothing in the core. val = -val; while (++mark <= sp) { I32 proc; + SvGETMAGIC(*mark); if (!(SvIOK(*mark) || SvNOK(*mark) || looks_like_number(*mark))) Perl_croak(aTHX_ "Can't kill a non-numeric process ID"); - proc = SvIV(*mark); + proc = SvIV_nomg(*mark); APPLY_TAINT_PROPER(); #ifdef HAS_KILLPG if (PerlProc_killpg(proc,val)) /* BSD */ @@ -1763,9 +1765,10 @@ nothing in the core. else { while (++mark <= sp) { I32 proc; + SvGETMAGIC(*mark); if (!(SvIOK(*mark) || SvNOK(*mark) || looks_like_number(*mark))) Perl_croak(aTHX_ "Can't kill a non-numeric process ID"); - proc = SvIV(*mark); + proc = SvIV_nomg(*mark); APPLY_TAINT_PROPER(); if (PerlProc_kill(proc, val)) tot--; diff --git a/t/op/kill0.t b/t/op/kill0.t index eadf15d..d3ef8f7 100644 --- a/t/op/kill0.t +++ b/t/op/kill0.t @@ -14,7 +14,7 @@ BEGIN { use strict; -plan tests => 5; +plan tests => 6; ok( kill(0, $$), 'kill(0, $pid) returns true if $pid exists' ); @@ -43,3 +43,10 @@ for my $case ( @bad_pids ) { like( $@, qr/^Can't kill a non-numeric process ID/, "dies killing $name pid"); } +# Verify that killing a magic variable containing a number doesn't +# trigger the above +{ + my $x = $$ . " "; + $x =~ /(\d+)/; + ok(eval { kill 0, $1 }, "can kill a number string in a magic variable"); +} -- Perl5 Master Repository