helly Sat Feb 18 17:11:06 2006 UTC Added files: (Branch: PHP_5_1) /php-src/ext/dba/tests bug36436.phpt
Modified files: /php-src NEWS /php-src/ext/dba dba_db4.c Log: - Fixed bug #36436 (DBA problem with Berkeley DB4). http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.418&r2=1.2027.2.419&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.418 php-src/NEWS:1.2027.2.419 --- php-src/NEWS:1.2027.2.418 Thu Feb 16 16:03:27 2006 +++ php-src/NEWS Sat Feb 18 17:11:06 2006 @@ -22,6 +22,7 @@ - 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). http://cvs.php.net/viewcvs.cgi/php-src/ext/dba/dba_db4.c?r1=1.15.2.2&r2=1.15.2.3&diff_format=u Index: php-src/ext/dba/dba_db4.c diff -u php-src/ext/dba/dba_db4.c:1.15.2.2 php-src/ext/dba/dba_db4.c:1.15.2.3 --- php-src/ext/dba/dba_db4.c:1.15.2.2 Sun Jan 1 12:50:05 2006 +++ php-src/ext/dba/dba_db4.c Sat Feb 18 17:11:06 2006 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba_db4.c,v 1.15.2.2 2006/01/01 12:50:05 sniper Exp $ */ +/* $Id: dba_db4.c,v 1.15.2.3 2006/02/18 17:11:06 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -139,9 +139,15 @@ 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 @@ 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; http://cvs.php.net/viewcvs.cgi/php-src/ext/dba/tests/bug36436.phpt?view=markup&rev=1.1 Index: php-src/ext/dba/tests/bug36436.phpt +++ php-src/ext/dba/tests/bug36436.phpt --TEST-- Bug #36436 DBA problem with Berkeley DB4 --SKIPIF-- <?php $handler = 'db4'; require_once('skipif.inc'); ?> --FILE-- <?php $handler = 'db4'; require_once('test.inc'); $db = dba_popen($db_filename, 'c', 'db4'); dba_insert('X', 'XYZ', $db); dba_insert('Y', '123', $db); var_dump($db, dba_fetch('X', $db)); var_dump(dba_firstkey($db)); var_dump(dba_nextkey($db)); dba_close($db); unlink($db_filename); ?> ===DONE=== --EXPECTF-- resource(%d) of type (dba persistent) string(3) "XYZ" string(1) "X" string(1) "Y" ===DONE=== -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php