diff options
author | Tony Cook <tony@develop-help.com> | 2020-01-21 16:12:44 +1100 |
---|---|---|
committer | Tony Cook <tony@develop-help.com> | 2020-01-27 10:23:08 +1100 |
commit | 4b004c43ef26ce175181122a7dfc3acd7dacb170 (patch) | |
tree | ae48b4be090b0bfa83e9d2f41b1439219372ec0a /pp_ctl.c | |
parent | 50f6cde683c695aeff81b1dc4ac2a3e447a2dd9f (diff) | |
download | perl-4b004c43ef26ce175181122a7dfc3acd7dacb170.tar.gz |
always treat undef in %INC as a failed require
Previously require would check for the specific \&PL_sv_undef
SV in %INC, this meant that if %INC was copied, or undef
assigned to a member the entry would erroneously be treated as if
a previous require of that file was successful.
So check for SvOK() instead, with appropriate magic tests.
fixes #17428
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -3861,7 +3861,7 @@ S_require_file(pTHX_ SV *sv) if (op_is_require) { /* can optimize to only perform one single lookup */ svp_cached = hv_fetch(GvHVn(PL_incgv), (char*) name, len, 0); - if ( svp_cached && *svp_cached != &PL_sv_undef ) RETPUSHYES; + if ( svp_cached && (SvGETMAGIC(*svp_cached), SvOK(*svp_cached)) ) RETPUSHYES; } #endif @@ -3906,7 +3906,10 @@ S_require_file(pTHX_ SV *sv) /* reuse the previous hv_fetch result if possible */ SV * const * const svp = svp_cached ? svp_cached : hv_fetch(GvHVn(PL_incgv), unixname, unixlen, 0); if ( svp ) { - if (*svp != &PL_sv_undef) + /* we already did a get magic if this was cached */ + if (!svp_cached) + SvGETMAGIC(*svp); + if (SvOK(*svp)) RETPUSHYES; else DIE(aTHX_ "Attempt to reload %s aborted.\n" |