diff options
author | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2017-06-01 17:33:15 +0100 |
---|---|---|
committer | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2017-06-05 16:06:41 +0100 |
commit | 520b6fb6871d18601e1bb968982f92f68ad523f5 (patch) | |
tree | 683f98ee12b928f043772e73fd3c4f91bbb13a76 /mg.c | |
parent | 8d37cdf70ae3493748b437390a3fa07a01fd07a9 (diff) | |
download | perl-520b6fb6871d18601e1bb968982f92f68ad523f5.tar.gz |
Forbid setting $/ to a reference to a non-postive integer
This used to work like setting it to 'undef', but has been deprecated
since Perl 5.20.
In passing, avoid duplicate duplicate uninitialized warning by reusing
the SvIV() result already stored in 'val'.
Diffstat (limited to 'mg.c')
-rw-r--r-- | mg.c | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -2915,7 +2915,6 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) break; case '/': { - SV *tmpsv = sv; if (SvROK(sv)) { SV *referent = SvRV(sv); const char *reftype = sv_reftype(referent, 0); @@ -2929,11 +2928,9 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) if (reftype[0] == 'S' || reftype[0] == 'L') { IV val = SvIV(referent); if (val <= 0) { - tmpsv = &PL_sv_undef; - Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED), - "Setting $/ to a reference to %s as a form of slurp is deprecated, treating as undef. This will be fatal in Perl 5.28", - SvIV(SvRV(sv)) < 0 ? "a negative integer" : "zero" - ); + sv_setsv(sv, PL_rs); + Perl_croak(aTHX_ "Setting $/ to a reference to %s is forbidden", + val < 0 ? "a negative integer" : "zero"); } } else { sv_setsv(sv, PL_rs); @@ -2943,7 +2940,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) } } SvREFCNT_dec(PL_rs); - PL_rs = newSVsv(tmpsv); + PL_rs = newSVsv(sv); } break; case '\\': |