summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--ext/dba/dba_db4.c8
-rw-r--r--ext/dba/tests/bug49125.phpt27
3 files changed, 36 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 644debe55a..313d84621f 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ PHP NEWS
- Fixed bug #49132 (posix_times returns false without error).
(phpbugs at gunnu dot us)
+- Fixed bug #49125 (Error in dba_exists C code). (jdornan at stanford dot edu)
- Fixed bug #49092 (ReflectionFunction fails to work with functions in fully
qualified namespaces). (Kalle, Jani)
- Fixed bug #49074 (private class static fields can be modified by using
diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c
index bcec74a01b..87c0e4c0e3 100644
--- a/ext/dba/dba_db4.c
+++ b/ext/dba/dba_db4.c
@@ -175,7 +175,15 @@ DBA_EXISTS_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 (info->flags & DBA_PERSISTENT) {
+ free(gval.data);
+ }
return SUCCESS;
}
return FAILURE;
diff --git a/ext/dba/tests/bug49125.phpt b/ext/dba/tests/bug49125.phpt
new file mode 100644
index 0000000000..3724b89c93
--- /dev/null
+++ b/ext/dba/tests/bug49125.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #49125 (Error in dba_exists C code)
+--SKIPIF--
+<?php
+ $handler = 'db4';
+ require_once dirname(__FILE__) .'/skipif.inc';
+?>
+--FILE--
+<?php
+
+error_reporting(E_ALL);
+
+$handler = 'db4';
+require_once dirname(__FILE__) .'/test.inc';
+
+$db = dba_popen($db_filename, 'c', 'db4');
+
+dba_insert('foo', 'foo', $db);
+
+var_dump(dba_exists('foo', $db));
+
+dba_close($db);
+
+unlink($db_filename);
+
+--EXPECT--
+bool(true)