Skip to content

Commit 085067a

Browse files
committed
- Fixed bug #49125 (Error in dba_exists C code)
patch by: jdornan at stanford dot edu
1 parent c75f162 commit 085067a

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHP NEWS
1010

1111
- Fixed bug #49132 (posix_times returns false without error).
1212
(phpbugs at gunnu dot us)
13+
- Fixed bug #49125 (Error in dba_exists C code). (jdornan at stanford dot edu)
1314
- Fixed bug #49092 (ReflectionFunction fails to work with functions in fully
1415
qualified namespaces). (Kalle, Jani)
1516
- Fixed bug #49074 (private class static fields can be modified by using

ext/dba/dba_db4.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,15 @@ DBA_EXISTS_FUNC(db4)
175175
DB4_GKEY;
176176

177177
memset(&gval, 0, sizeof(gval));
178+
179+
if (info->flags & DBA_PERSISTENT) {
180+
gval.flags |= DB_DBT_MALLOC;
181+
}
182+
178183
if (!dba->dbp->get(dba->dbp, NULL, &gkey, &gval, 0)) {
184+
if (info->flags & DBA_PERSISTENT) {
185+
free(gval.data);
186+
}
179187
return SUCCESS;
180188
}
181189
return FAILURE;

ext/dba/tests/bug49125.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Bug #49125 (Error in dba_exists C code)
3+
--SKIPIF--
4+
<?php
5+
$handler = 'db4';
6+
require_once dirname(__FILE__) .'/skipif.inc';
7+
?>
8+
--FILE--
9+
<?php
10+
11+
error_reporting(E_ALL);
12+
13+
$handler = 'db4';
14+
require_once dirname(__FILE__) .'/test.inc';
15+
16+
$db = dba_popen($db_filename, 'c', 'db4');
17+
18+
dba_insert('foo', 'foo', $db);
19+
20+
var_dump(dba_exists('foo', $db));
21+
22+
dba_close($db);
23+
24+
unlink($db_filename);
25+
26+
--EXPECT--
27+
bool(true)

0 commit comments

Comments
 (0)