json_parse()/pgtypes: Fix accidental creation of read-only array/hash values
&PL_sv_* shouldn't be used when constructing arrays or hashes in this context.
This commit is contained in:
parent
817fa600d0
commit
d0c5397e2d
8 changed files with 45 additions and 11 deletions
|
|
@ -2,7 +2,7 @@ use v5.36;
|
|||
use Test::More;
|
||||
use FU::Util 'json_parse';
|
||||
no warnings 'experimental::builtin';
|
||||
use builtin 'is_bool', 'created_as_number';
|
||||
use builtin 'is_bool', 'created_as_number', 'true', 'false';
|
||||
use Config;
|
||||
|
||||
my @error = (
|
||||
|
|
@ -236,4 +236,10 @@ ok !eval { json_parse '{"":{"":{"":{"":1}}}}', max_depth => 4; 1 };
|
|||
ok !eval { json_parse '"string"', max_size => 7 };
|
||||
}
|
||||
|
||||
# Mutable hashes/arrays
|
||||
my $d = json_parse('[true,false,null,{"a":true,"b":false,"c":null}]');
|
||||
is_deeply $d, [true,false,undef,{a => true, b => false, c => undef}];
|
||||
$_ = 1 for @{$d}[0,1,2], values $d->[3]->%*;
|
||||
is_deeply $d, [1,1,1,{a => 1, b => 1, c => 1}];
|
||||
|
||||
done_testing;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue