diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:28 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:28 -0400 |
commit | ba50031707469046407a35b77a3cd81351e951b3 (patch) | |
tree | 5c03e723bdbfabae09d41a3ab1253dff41eeed4a /ext/dba | |
parent | 0a36161e13484a99ccf69bb38f206462d27cc6d6 (diff) | |
download | php-ba50031707469046407a35b77a3cd81351e951b3.tar.gz |
Imported Upstream version 5.1.5upstream/5.1.5
Diffstat (limited to 'ext/dba')
-rw-r--r-- | ext/dba/dba_db4.c | 20 | ||||
-rwxr-xr-x | ext/dba/tests/bug36436.phpt | 34 |
2 files changed, 53 insertions, 1 deletions
diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index 79c1e80b6..25e66ab0f 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -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 @@ 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 000000000..e85cf8528 --- /dev/null +++ b/ext/dba/tests/bug36436.phpt @@ -0,0 +1,34 @@ +--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=== |