Index: ext/standard/array.c =================================================================== RCS file: /repository/php-src/ext/standard/array.c,v retrieving revision 1.308.2.21.2.37.2.24 diff -u -r1.308.2.21.2.37.2.24 array.c --- ext/standard/array.c 14 Feb 2008 14:08:22 -0000 1.308.2.21.2.37.2.24 +++ ext/standard/array.c 15 Feb 2008 09:16:56 -0000 @@ -275,6 +275,12 @@ zval **element; if (Z_TYPE_P(array) == IS_ARRAY) { + + if (Z_ARRVAL_P(array)->nApplyCount > 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "recursion detected"); + return 0; + } + cnt = zend_hash_num_elements(Z_ARRVAL_P(array)); if (mode == COUNT_RECURSIVE) { HashPosition pos; @@ -283,7 +289,9 @@ zend_hash_get_current_data_ex(Z_ARRVAL_P(array), (void **) &element, &pos) == SUCCESS; zend_hash_move_forward_ex(Z_ARRVAL_P(array), &pos) ) { + Z_ARRVAL_P(array)->nApplyCount++; cnt += php_count_recursive(*element, COUNT_RECURSIVE TSRMLS_CC); + Z_ARRVAL_P(array)->nApplyCount--; } } }