diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-06-24 11:14:29 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-06-24 11:14:29 -0700 |
commit | 0a5f3363e275bb35c4f20083e44a319e37d56898 (patch) | |
tree | a425cbe153822000d2b471488a0cc1de4fd51b8f | |
parent | 61a3fb803c3babf0e3e750430415338e6506a241 (diff) | |
download | perl-0a5f3363e275bb35c4f20083e44a319e37d56898.tar.gz |
Don’t crash with ()=&CORE::srand
Ops that don’t allow arbitrarily long argument lists are flagged at compile-time with the number of children.
Coresubs have to call the same op with differing numbers of arguments,
so they push nulls on to the stack to make up the number of items the
pp function expects to pop.
Commit f914a6829 stopped popping the null of the stack.
Before:
$ ./perl -le 'print &CORE::srand'
1240765685
After:
$ ./perl -le 'print &CORE::srand'
Bus error
List assignment does the same thing, and makes it easier to
write a test.
-rw-r--r-- | pp.c | 2 | ||||
-rw-r--r-- | t/op/coreamp.t | 1 |
2 files changed, 2 insertions, 1 deletions
@@ -2660,7 +2660,7 @@ PP(pp_srand) dVAR; dSP; dTARGET; UV anum; - if (MAXARG >= 1 && TOPs) { + if (MAXARG >= 1 && (TOPs || POPs)) { SV *top; char *pv; STRLEN len; diff --git a/t/op/coreamp.t b/t/op/coreamp.t index 93e2c51e28..11ddc796fa 100644 --- a/t/op/coreamp.t +++ b/t/op/coreamp.t @@ -802,6 +802,7 @@ test_proto 'sqrt', 4, 2; test_proto 'srand'; $tests ++; &CORE::srand; +() = &CORE::srand; pass '&srand with no args does not crash'; test_proto 'study'; |