Skip to content

Commit 75c5712

Browse files
committed
Fixed bug #64997 (Segfault while using RecursiveIteratorIterator on 64-bits systems)
1 parent e8f004d commit 75c5712

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ PHP NEWS
1717
. Fixed bug #64949 (Buffer overflow in _pdo_pgsql_error). (Remi)
1818

1919
- pgsql:
20-
- Fixed bug #64609 (pg_convert enum type support). (Matteo)
20+
. Fixed bug #64609 (pg_convert enum type support). (Matteo)
21+
22+
- SPL:
23+
. Fixed bug #64997 (Segfault while using RecursiveIteratorIterator on
24+
64-bits systems). (Laruence)
2125

2226
06 Jun 2013, PHP 5.3.26
2327

ext/spl/spl_iterators.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,12 +1025,12 @@ static void spl_recursive_tree_iterator_get_entry(spl_recursive_it_object * obje
10251025
zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
10261026
if (data && *data) {
10271027
RETVAL_ZVAL(*data, 1, 0);
1028-
}
1029-
if (Z_TYPE_P(return_value) == IS_ARRAY) {
1030-
zval_dtor(return_value);
1031-
ZVAL_STRINGL(return_value, "Array", sizeof("Array")-1, 1);
1032-
} else {
1033-
convert_to_string(return_value);
1028+
if (Z_TYPE_P(return_value) == IS_ARRAY) {
1029+
zval_dtor(return_value);
1030+
ZVAL_STRINGL(return_value, "Array", sizeof("Array")-1, 1);
1031+
} else {
1032+
convert_to_string(return_value);
1033+
}
10341034
}
10351035
zend_restore_error_handling(&error_handling TSRMLS_CC);
10361036
}
@@ -1131,8 +1131,15 @@ SPL_METHOD(RecursiveTreeIterator, current)
11311131
}
11321132
}
11331133

1134+
INIT_ZVAL(prefix);
1135+
INIT_ZVAL(entry);
11341136
spl_recursive_tree_iterator_get_prefix(object, &prefix TSRMLS_CC);
11351137
spl_recursive_tree_iterator_get_entry(object, &entry TSRMLS_CC);
1138+
if (Z_TYPE(entry) != IS_STRING) {
1139+
zval_dtor(&prefix);
1140+
zval_dtor(&entry);
1141+
RETURN_NULL();
1142+
}
11361143
spl_recursive_tree_iterator_get_postfix(object, &postfix TSRMLS_CC);
11371144

11381145
str_len = Z_STRLEN(prefix) + Z_STRLEN(entry) + Z_STRLEN(postfix);

0 commit comments

Comments
 (0)