diff --git a/NEWS b/NEWS index f162756d4c59..ea28a2ba33e0 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,10 @@ PHP NEWS - Curl: . Fix various memory leaks in curl mime handling. (nielsdos) +- DBA: + . Fixed bug GH-16990 (dba_list() is now zero-indexed instead of using + resource ids) (kocsismate) + - DOM: . Fixed bug GH-16906 (Reloading document can cause UAF in iterator). (nielsdos) diff --git a/ext/dba/dba.c b/ext/dba/dba.c index f094fb1f612b..e4986e1cd232 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -1293,9 +1293,9 @@ PHP_FUNCTION(dba_list) zval *zv; ZEND_HASH_MAP_FOREACH_VAL(&DBA_G(connections), zv) { - dba_info *info = Z_DBA_INFO_P(zv); - if (info) { - add_next_index_str(return_value, zend_string_copy(info->path)); + dba_connection *connection = Z_DBA_CONNECTION_P(zv); + if (connection->info) { + add_index_str(return_value, connection->std.handle, zend_string_copy(connection->info->path)); } } ZEND_HASH_FOREACH_END(); } diff --git a/ext/dba/tests/gh16990.phpt b/ext/dba/tests/gh16990.phpt new file mode 100644 index 000000000000..f3191904722b --- /dev/null +++ b/ext/dba/tests/gh16990.phpt @@ -0,0 +1,46 @@ +--TEST-- +GH-16990 (dba_list() is now zero-indexed instead of using resource ids) +--EXTENSIONS-- +dba +--CONFLICTS-- +dba +--SKIPIF-- + +--FILE-- + +--CLEAN-- + +--EXPECTF-- +array(2) { + [2]=> + string(%d) "%s%etest1.dbm" + [4]=> + string(%d) "%s%etest2.dbm" +}