Possible bug in array handling dbd-pg 2.17.1
Paul Bagyenda <[email protected]> Tue, 6 Jul 2010 11:43:30 +0200
| Newsgroups | gmane.comp.db.postgresql.dbdpg |
|---|---|
| Message-ID | <[email protected]> |
Hi, I tripped over a case where dbd-pg 2.17.1 crashes under Bucardo (burcardo.org). Based on the gdb backtrace, I was able to track it down and fix with the patch attached. I am not able to reproduce the bug with smaller perl scripts, but the situation is as follows: - When transfering PostgreSQL bigint array's that contain NULL array entries, dbd-pg causes perl to crash on SuSE 11.1 Sorry I can't be more specific :( Paul.
dbd-pg-2.17.1.diff
(application/octet-stream, 884 B)
diff -Naur /tmp/DBD-Pg-2.17.1/dbdimp.c DBD-Pg-2.17.1/dbdimp.c
--- /tmp/DBD-Pg-2.17.1/dbdimp.c 2010-04-07 22:49:52.000000000 +0200
+++ DBD-Pg-2.17.1/dbdimp.c 2010-05-31 13:11:30.000000000 +0200
@@ -2472,12 +2472,15 @@
sv_catpv(value, "{");
}
for (yz=0; yz < array_items; yz++) {
- svitem = *av_fetch(currarr, yz, 0);
-
- if (SvROK(svitem))
+ SV **svitem_ptr = av_fetch(currarr, yz, 0);
+ if (svitem_ptr)
+ svitem = *svitem_ptr;
+ else
+ svitem = NULL;
+ if (svitem != NULL && SvROK(svitem))
croak("Arrays must contain only scalars and other arrays");
- if (!SvOK(svitem)) { /* Insert NULL if we can */
+ if (svitem == NULL || !SvOK(svitem)) { /* Insert NULL if we can */
/* Only version 8.2 and up can handle NULLs in arrays */
if (server_version < 80200)
croak("Cannot use NULLs in arrays until version 8.2");