From 085067a9aa7c1c4feed5b669d7fe251a482dc10b Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Sat, 1 Aug 2009 23:10:11 +0000 Subject: [PATCH] - Fixed bug #49125 (Error in dba_exists C code) patch by: jdornan at stanford dot edu --- NEWS | 1 + ext/dba/dba_db4.c | 8 ++++++++ ext/dba/tests/bug49125.phpt | 27 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 ext/dba/tests/bug49125.phpt 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-- + +--FILE-- +