diff options
-rw-r--r-- | gv.c | 2 | ||||
-rw-r--r-- | pp.c | 2 | ||||
-rw-r--r-- | t/op/coreamp.t | 6 |
3 files changed, 8 insertions, 2 deletions
@@ -1360,7 +1360,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, case KEY_push: case KEY_setpgrp: case KEY_shift: case KEY_splice: - case KEY_srand: case KEY_stat: case KEY_substr: + case KEY_stat: case KEY_substr: case KEY_sysopen: case KEY_system: case KEY_tell: case KEY_tie: case KEY_tied: @@ -2832,7 +2832,7 @@ PP(pp_rand) PP(pp_srand) { dVAR; dSP; dTARGET; - const UV anum = (MAXARG < 1) ? seed() : POPu; + const UV anum = (MAXARG < 1 || (!TOPs && !POPs)) ? seed() : POPu; (void)seedDrand01((Rand_seed_t)anum); PL_srand_called = TRUE; if (anum) diff --git a/t/op/coreamp.t b/t/op/coreamp.t index 03fc14f098..b9b946fbe0 100644 --- a/t/op/coreamp.t +++ b/t/op/coreamp.t @@ -664,6 +664,12 @@ is &mysprintf("%x", 65), '41', '&sprintf'; lis [&mysprintf("%x", '65')], ['41'], '&sprintf in list context'; test_proto 'sqrt', 4, 2; + +test_proto 'srand'; +$tests ++; +&CORE::srand; +pass '&srand with no args does not crash'; + test_proto 'symlink'; test_proto 'syscall'; test_proto 'sysread'; |