]> 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

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

index df20ac7d1e5e8524dbf2fc2d717911360f63115d..448dd4f9eabe0bf769b4d862a27b7c76243504d7 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)