From: Marcus Boerger Date: Sat, 18 Feb 2006 17:11:06 +0000 (+0000) Subject: - Fixed bug #36436 (DBA problem with Berkeley DB4). X-Git-Tag: php-5.1.3RC1~93 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=78516c79059e9566cb573998497bd72b7be1a0dc;p=php - Fixed bug #36436 (DBA problem with Berkeley DB4). --- diff --git a/NEWS b/NEWS index 4ebc17c50b..c29e7dd1c8 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,7 @@ PHP NEWS - Added ReflectionClass::newInstanceArgs($args). (Marcus) - Added imap_savebody() that allows message body to be written to a file. (Mike) +- Fixed bug #36436 (DBA problem with Berkeley DB4). (Marcus) - Fixed bug #36420 (segfault when access result->num_rows after calling result->close()). (Ilia) - Fixed bug #36403 (oci_execute() no longer supports OCI_DESCRIBE_ONLY). diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index ddfdf341b1..994dd8bd67 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -139,9 +139,15 @@ DBA_FETCH_FUNC(db4) DB4_GKEY; memset(&gval, 0, sizeof(gval)); + if (info->flags & DBA_PERSISTENT) { + gval.flags |= DB_DBT_MALLOC; + } if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) { if (newlen) *newlen = gval.size; new = estrndup(gval.data, gval.size); + if (info->flags & DBA_PERSISTENT) { + free(gval.data); + } } return new; } @@ -210,11 +216,23 @@ DBA_NEXTKEY_FUNC(db4) memset(&gkey, 0, sizeof(gkey)); memset(&gval, 0, sizeof(gval)); + if (info->flags & DBA_PERSISTENT) { + gkey.flags |= DB_DBT_MALLOC; + gval.flags |= DB_DBT_MALLOC; + } if (dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) == 0) { if (gkey.data) { nkey = estrndup(gkey.data, gkey.size); if (newlen) *newlen = gkey.size; } + if (info->flags & DBA_PERSISTENT) { + if (gkey.data) { + free(gkey.data); + } + if (gval.data) { + free(gval.data); + } + } } return nkey; diff --git a/ext/dba/tests/bug36436.phpt b/ext/dba/tests/bug36436.phpt new file mode 100755 index 0000000000..e85cf85282 --- /dev/null +++ b/ext/dba/tests/bug36436.phpt @@ -0,0 +1,34 @@ +--TEST-- +Bug #36436 DBA problem with Berkeley DB4 +--SKIPIF-- + +--FILE-- + +===DONE=== +--EXPECTF-- +resource(%d) of type (dba persistent) +string(3) "XYZ" +string(1) "X" +string(1) "Y" +===DONE===