Author: turnstep
Date: Wed Oct 15 17:49:02 2008
New Revision: 11981
Modified:
DBD-Pg/trunk/Changes
DBD-Pg/trunk/dbdimp.c
DBD-Pg/trunk/t/12placeholders.t
Log:
Fix bug 40075
Modified: DBD-Pg/trunk/Changes
==============================================================================
--- DBD-Pg/trunk/Changes (original)
+++ DBD-Pg/trunk/Changes Wed Oct 15 17:49:02 2008
@@ -1,6 +1,11 @@
('GSM' is Greg Sabino Mullane, [EMAIL PROTECTED])
-2.11.1 Released October 14, 2008
+
+2.11.2 Released October 15, 2008
+
+ - Fix core dump when invalid placeholders used. (CPAN bug #40075) [GSM]
+
+2.11.1 Released October 14, 2008 (subversion r11980)
- $sth->{ParamTypes} returns 'TYPE' when possible.
Modified: DBD-Pg/trunk/dbdimp.c
==============================================================================
--- DBD-Pg/trunk/dbdimp.c (original)
+++ DBD-Pg/trunk/dbdimp.c Wed Oct 15 17:49:02 2008
@@ -3037,7 +3037,8 @@
New(0, statement, execsize+1, char); /* freed below */
statement[0] = '\0';
for (currseg=imp_sth->seg; NULL != currseg;
currseg=currseg->nextseg) {
- strcat(statement, currseg->segment);
+ if (currseg->segment != NULL)
+ strcat(statement, currseg->segment);
if (currseg->placeholder!=0)
sprintf(strchr(statement, '\0'), "$%d",
currseg->placeholder);
}
@@ -3097,7 +3098,8 @@
New(0, statement, execsize+1, char); /* freed below */
statement[0] = '\0';
for (currseg=imp_sth->seg; NULL != currseg;
currseg=currseg->nextseg) {
- strcat(statement, currseg->segment);
+ if (currseg->segment != NULL)
+ strcat(statement, currseg->segment);
if (currseg->placeholder!=0)
strcat(statement, currseg->ph->quoted);
}
Modified: DBD-Pg/trunk/t/12placeholders.t
==============================================================================
--- DBD-Pg/trunk/t/12placeholders.t (original)
+++ DBD-Pg/trunk/t/12placeholders.t Wed Oct 15 17:49:02 2008
@@ -15,7 +15,7 @@
if (! defined $dbh) {
plan skip_all => 'Connection to database failed, cannot continue
testing';
}
-plan tests => 27;
+plan tests => 28;
my $t='Connect to database for placeholder testing';
isnt ($dbh, undef, $t);
@@ -152,6 +152,13 @@
};
is ($@, q{}, $t);
+$t='Calling do() with invalid crowded placeholders fails cleanly';
+$dbh->commit();
+eval {
+ $dbh->do(q{SELECT ??}, undef, 'public', 'error');
+};
+like ($@, qr{ERROR}, $t);
+
$t='Prepare/execute with non-DML placeholder works';
$dbh->commit();
eval {