diff options
author | Nicholas Clark <nick@ccl4.org> | 2021-10-16 07:52:56 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2021-10-20 15:34:23 +0000 |
commit | 7c4cc0343c223680358a798ea6826c8c3a710db3 (patch) | |
tree | ae5a1b05c2476ea9c6122c66700c9acf705bcd45 /hv.c | |
parent | 638b4d9051af3a8aa432795a1f33508001c1754e (diff) | |
download | perl-7c4cc0343c223680358a798ea6826c8c3a710db3.tar.gz |
Perl_newHVhv() did not correctly copy hashes with non-shared keys
It created a hash built with non-shared keys, but left the "shared keys"
flag set on the hash.
This hasn't been spotted in 20 years, which shows just how much we use
hashes with unshared keys.
Diffstat (limited to 'hv.c')
-rw-r--r-- | hv.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -1593,6 +1593,14 @@ Perl_newHVhv(pTHX_ HV *ohv) Newx(a, PERL_HV_ARRAY_ALLOC_BYTES(hv_max+1), char); ents = (HE**)a; + if (shared) { + /* Shared is the default - it should have been set by newHV(). */ + assert(HvSHAREKEYS(hv)); + } + else { + HvSHAREKEYS_off(hv); + } + /* In each bucket... */ for (i = 0; i <= hv_max; i++) { HE *prev = NULL; |