]> granicus.if.org Git - php/commitdiff
- MFH: Fixed bug #48240 (DBA Segmentation fault dba_nextkey)
authorFelipe Pena <felipe@php.net>
Wed, 13 May 2009 02:16:36 +0000 (02:16 +0000)
committerFelipe Pena <felipe@php.net>
Wed, 13 May 2009 02:16:36 +0000 (02:16 +0000)
NEWS
ext/dba/dba_db4.c
ext/dba/tests/bug48240.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 296fd44fa712b2f388b9515b0e11813da3ee05e0..f9ef5b314e0985326cd9913ca17e012a36a8cc0b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ PHP                                                                        NEWS
 
 - Fixed bug #48248 (SIGSEGV when access to private property via &__get). 
   (Felipe)
+- Fixed bug #48240 (DBA Segmentation fault dba_nextkey). (Felipe)
 - Fixed bug #48224 (Incorrect shuffle in array_rand). (Etienne)
 - Fixed bug #48221 (memory leak when passing invalid xslt parameter). (Felipe)
 - Fixed bug #48206 (Iterating over an invalid data structure
index 8e1433971168729c445fee7a7a03cbfbd50cfb39..bcec74a01b46a038b811c00558203dd45b02e3e8 100644 (file)
@@ -219,7 +219,7 @@ DBA_NEXTKEY_FUNC(db4)
                gkey.flags |= DB_DBT_MALLOC;
                gval.flags |= DB_DBT_MALLOC;
        }
-       if (dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) == 0) {
+       if (dba->cursor && dba->cursor->c_get(dba->cursor, &gkey, &gval, DB_NEXT) == 0) {
                if (gkey.data) {
                        nkey = estrndup(gkey.data, gkey.size);
                        if (newlen) *newlen = gkey.size;
diff --git a/ext/dba/tests/bug48240.phpt b/ext/dba/tests/bug48240.phpt
new file mode 100644 (file)
index 0000000..72dc439
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+Bug #48240 (DBA Segmentation fault dba_nextkey)
+--SKIPIF--
+<?php 
+       $handler = 'db4';
+       require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+$handler = 'db4';
+require_once('test.inc');
+
+$db = dba_open($db_filename, 'c', 'db4');
+
+var_dump(dba_nextkey($db));
+
+dba_close($db);
+unlink($db_filename);
+
+?>
+===DONE===
+--EXPECT--
+bool(false)
+===DONE===