Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 4578
Status: resolved
Priority: 0/
Queue: DBD-Pg

Owner: Nobody in particular

Bug Information
Severity: Important
Broken in: 1.31
Fixed in: 1.32


Subject: $sth->execute( undef ) causes "Bad free() ignored (PERL_CORE)"
Download (untitled) / with headers
text/plain 900b
If $sth->execute is called with undef for placeholder value, statement deallocation (when $sth goes out of scope, for example) causes "Bad free() ignored (PERL_CORE)". It may require several execute() calls to happen, but then it will be displayed after each call to execute with undef values. Here is simplified code: ---- use DBI; my $dbh = DBI->connect( 'dbi:Pg:dbname=test', 'test', '', { AutoCommit => 1 } ); for( my $i = 0; $i < 100; $i++ ) { print STDERR "$i\n"; bug(); } $dbh->disconnect; exit; sub bug { my $sth = $dbh->prepare( q{SELECT name FROM t WHERE id IN (?, ?)} ); $sth->execute( undef, undef ); } ----- The problem is in dbdimp.c line 860: phs->quoted = strdup("NULL"); When safefree(phs_tpl->quoted) in called later in line 1147, "Bad free() ignored" warning appears because strdup doesn't use perl's safemalloc. I have created simple patch for this problem.
Download dbdpg.patch
text/x-diff 637b
diff -ru DBD-Pg-1.31.old/dbdimp.c DBD-Pg-1.31/dbdimp.c --- DBD-Pg-1.31.old/dbdimp.c Mon Oct 27 19:57:02 2003 +++ DBD-Pg-1.31/dbdimp.c Thu Dec 4 16:24:33 2003 @@ -857,9 +857,10 @@ if (!SvOK(newvalue)) { - phs->quoted = strdup("NULL"); + phs->quoted = safemalloc(sizeof("NULL")); if (NULL == phs->quoted) croak("No memory"); + strcpy(phs->quoted, "NULL"); phs->quoted_len = strlen(phs->quoted); } else { value_string = SvPV(newvalue, value_len);

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to