SEEN(hv, cname, 0); /* Will return if table not allocated properly */
if (len == 0)
return (SV *) hv; /* No data follow if table empty */
- hv_ksplit(hv, len); /* pre-extend hash to save multiple splits */
+ hv_ksplit(hv, len + 1); /* pre-extend hash to save multiple splits */
/*
* Now get each key/value pair in turn...
SEEN(hv, cname, 0); /* Will return if table not allocated properly */
if (len == 0)
return (SV *) hv; /* No data follow if table empty */
- hv_ksplit(hv, len); /* pre-extend hash to save multiple splits */
+ hv_ksplit(hv, len + 1); /* pre-extend hash to save multiple splits */
/*
* Now get each key/value pair in turn...
SEEN(hv, 0, 0); /* Will return if table not allocated properly */
if (len == 0)
return (SV *) hv; /* No data follow if table empty */
- hv_ksplit(hv, len); /* pre-extend hash to save multiple splits */
+ hv_ksplit(hv, len + 1); /* pre-extend hash to save multiple splits */
/*
* Now get each key/value pair in turn...
use Storable qw(dclone freeze thaw);
use Hash::Util qw(lock_hash unlock_value lock_keys);
-use Test::More tests => 104;
+use Test::More tests => 304;
my %hash = (question => '?', answer => 42, extra => 'junk', undef => undef);
lock_hash %hash;
ok eval { $$hv2{a} = 70 }, 'COWs do not become read-only';
}
}
+
+# [perl #73972]
+{
+ for my $n (1..100) {
+ my @keys = map { "FOO$_" } (1..$n);
+
+ my $hash1 = {};
+ lock_keys(%$hash1, @keys);
+ my $hash2 = dclone($hash1);
+
+ my $success;
+
+ $success = eval { $hash2->{$_} = 'test' for @keys; 1 };
+ my $err = $@;
+ ok($success, "can store in all of the $n restricted slots")
+ || diag("failed with $@");
+
+ $success = !eval { $hash2->{a} = 'test'; 1 };
+ ok($success, "the hash is still restricted");
+ }
+}