diff options
author | Nicholas Clark <nick@ccl4.org> | 2021-07-04 19:23:05 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2022-02-19 19:46:37 +0000 |
commit | 59cc2f5b2548d81765e9f3dc2ce10c1070e787b8 (patch) | |
tree | ec8d7cdf97a60470fe38ebcf0fcbbed90a61626b | |
parent | cff76435bba3c0cf32c22b33ad9f14672094c90b (diff) | |
download | perl-59cc2f5b2548d81765e9f3dc2ce10c1070e787b8.tar.gz |
Copy values that are "written as IV, then read as PV" with the same flags.
Previously Perl_sv_setsv_flags() would gleefully turn on SVf_POK for these
values, which meant that any copy no longer propagated the (new) state
that says "this value started as an integer".
-rw-r--r-- | sv.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -4892,6 +4892,12 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags) SvIV_set(dsv, SvIVX(ssv)); if (sflags & SVf_IVisUV) SvIsUV_on(dsv); + if ((sflags & SVf_IOK) && !(sflags & SVf_POK)) { + /* Source was SVf_IOK|SVp_IOK|SVp_POK but not SVf_POK, meaning + a value set as an integer and later stringified. So mark + destination the same: */ + SvFLAGS(dsv) &= ~SVf_POK; + } } SvFLAGS(dsv) |= sflags & (SVf_IOK|SVp_IOK|SVf_NOK|SVp_NOK|SVf_UTF8); { |