diff options
author | Yves Orton <demerphq@gmail.com> | 2014-07-30 15:44:44 +0200 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2014-07-30 15:44:47 +0200 |
commit | f04d2c345149d984ed5180f12fa007908c91b131 (patch) | |
tree | d80ea12650d331421ef76dd4dc836b9b590580a7 /pp_ctl.c | |
parent | 57d69a4016b981268198cf744741335a9b1fbb23 (diff) | |
download | perl-f04d2c345149d984ed5180f12fa007908c91b131.tar.gz |
make "require" handle no argument more gracefully, and add tests
in Perl 5.14 the following segfaults:
*CORE::GLOBAL::require = sub { }; eval "require";
in Perl 5.18
perl -wle'eval "require";'
produces a spurious warning:
Use of uninitialized value $_ in require at (eval 1) line 1.
In other perls:
perl -e 'eval q/require $this/ or print $@'
produces:
Null filename used at (eval 1) line 1.
The error message is crappy, totally unfit for a perl audience,
and the spurious warning is just confusing. There is no $_ in use
here, why do we warn about it.
It looks like 9e3fb20c fixed the segfault (by accident), and also
somehow meant that the "Null filename" error would not ever be
produced.
So this patch ditches the crappy error and replaces it with something
meaningful and informative, and tests that we do not regress and start
segfaulting again.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -3737,9 +3737,12 @@ PP(pp_require) RETPUSHYES; } + if (!SvOK(sv)) + DIE(aTHX_ "Missing or undefined argument to require"); name = SvPV_const(sv, len); if (!(name && len > 0 && *name)) - DIE(aTHX_ "Null filename used"); + DIE(aTHX_ "Missing or undefined argument to require"); + if (!IS_SAFE_PATHNAME(name, len, "require")) { DIE(aTHX_ "Can't locate %s: %s", pv_escape(newSVpvs_flags("",SVs_TEMP),SvPVX(sv),SvCUR(sv), |