Skip to content

Commit

Permalink
hv.c: ALWAYS perform in_collision check
Browse files Browse the repository at this point in the history
This is a critical patch. Any perl built with the previous code
without PERL_HASH_RANDOMIZE_KEYS would never perform a key split!
  • Loading branch information
demerphq committed Mar 5, 2022
1 parent 1bd2ffc commit a977878
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hv.c
Expand Up @@ -849,14 +849,14 @@ Perl_hv_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen,
HeKEY_hek(entry) = save_hek_flags(key, klen, hash, flags);
}
HeVAL(entry) = val;
in_collision = cBOOL(*oentry != NULL);

#ifdef PERL_HASH_RANDOMIZE_KEYS
/* This logic semi-randomizes the insert order in a bucket.
* Either we insert into the top, or the slot below the top,
* making it harder to see if there is a collision. We also
* reset the iterator randomizer if there is one.
*/
in_collision = *oentry != NULL;
if ( *oentry && PL_HASH_RAND_BITS_ENABLED) {
PL_hash_rand_bits++;
PL_hash_rand_bits= ROTL_UV(PL_hash_rand_bits,1);
Expand Down

0 comments on commit a977878

Please sign in to comment.