File: 121_memleak.t

package info (click to toggle)
libcpanel-json-xs-perl 4.39-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,872 kB
  • sloc: perl: 1,165; makefile: 8
file content (21 lines) | stat: -rw-r--r-- 464 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use strict;
use warnings;

use Cpanel::JSON::XS;
use Devel::Peek;

# Devel::Peek::SvREFCNT(%hash) is supported since 5.19.3
use Test::More ($] < 5.019003) ? (skip_all => "5.19.3") : (tests => 1);

my $json = Cpanel::JSON::XS->new;

my $x = '{"some": "json"}';
$json->decode($x, my $types);
is(Devel::Peek::SvREFCNT(%{$types}), 1);

__END__
# Following code triggers memory leak when SvREFCNT is not 1
for (1..5000000) {
    my $var;
    $json->decode($x, $var);
}