Subject: | Segmentation fault when fetchrow() is called too many times |
Hi,
DBD::SQLite2 crashes with a segmentation fault when fetchrow() is called
again after it has returned an empty list (ie. the query has completed).
Please consider the attached testcase. It crashes with 0.33 on both Perl 5.8.4 and 5.8.7 on Debian GNU/Linux 3.1 ("sarge") and unstable ("sid").
This bug report was originally filed as Debian bug #317453, http://bugs.debian.org/317453
Cheers,
--
Niko Tyni
ntyni@iki.fi
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my($dbh,$q);
unlink("test.db");
$dbh = DBI->connect("dbi:SQLite2:test.db");
my $create = <<EOF;
create table test (id INTEGER PRIMARY KEY, col1 INTEGER, col2 INTEGER);
insert into test (id, col1, col2) values (1, 1, 0);
EOF
for (split(/\n/, $create)) { $dbh->do($_); }
$q = $dbh->prepare("SELECT * FROM test WHERE col1 = ?");
$q->execute(1);
my $delayed = 0;
my (@row);
while (1) {
if (@row = $q->fetchrow()) {
print "q fetch, id=$row[0], col1=$row[1], col2=$row[2]\n";
} else {
last if $delayed++;
}
}