]> granicus.if.org Git - php/commitdiff
- Fixed bug #49125 (Error in dba_exists C code)
authorFelipe Pena <felipe@php.net>
Sat, 1 Aug 2009 23:10:11 +0000 (23:10 +0000)
committerFelipe Pena <felipe@php.net>
Sat, 1 Aug 2009 23:10:11 +0000 (23:10 +0000)
  patch by: jdornan at stanford dot edu

NEWS
ext/dba/dba_db4.c
ext/dba/tests/bug49125.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 644debe55a4747db30c6dd1ddcc04bd54f5b6ce4..313d84621f8b8a2ec270b1a2a3c8ac295a0edb3c 100644 (file)
--- 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
index bcec74a01b46a038b811c00558203dd45b02e3e8..87c0e4c0e37a5e6f0bbf434433958299a512d132 100644 (file)
@@ -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 (file)
index 0000000..3724b89
--- /dev/null
@@ -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)