Subject: | Access to $sth->{ParamValues} leaks |
Seems like library returns the wrong refcount? Forget to release pvhv?
if (strEQ(key, "ParamValues"))
{
HV *pvhv= newHV();
if (DBIc_NUM_PARAMS(imp_sth))
{
int n;
char key[100];
I32 keylen;
for (n= 0; n < DBIc_NUM_PARAMS(imp_sth); n++)
{
keylen= sprintf(key, "%d", n);
hv_store(pvhv, key,
keylen, newSVsv(imp_sth->params[n].value), 0);
}
}
retsv= newRV_noinc((SV*)pvhv);
}
Subject: | test-leaky-mysql.pl |
#!/usr/bin/perl -w
use strict;
use DBI;
use Data::Dumper;
# CREATE DATABASE test;
# USE test;
# CREATE TABLE `employee` (
# `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
# PRIMARY KEY (`id`)
# ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
my $dbh = DBI->connect("DBI:mysql:database=test;host=localhost","root",undef);
my $sth = $dbh->prepare("SELECT * FROM employee WHERE id = ?");
while (1) {
$sth->execute('123456789');
my $row = $sth->fetchrow_hashref();
print Data::Dumper->Dump([$sth->{ParamValues}]);
$sth->finish();
}