colder Sun Oct 19 18:00:42 2008 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/spl spl_array.c
/php-src/ext/spl/tests arrayObject___construct_error1.phpt
arrayObject_setIteratorClass_error1.phpt
Log:
MFB: Fix #46317 (Iterator class not properly checked)
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_array.c?r1=1.71.2.17.2.20&r2=1.71.2.17.2.21&diff_format=u
Index: php-src/ext/spl/spl_array.c
diff -u php-src/ext/spl/spl_array.c:1.71.2.17.2.20
php-src/ext/spl/spl_array.c:1.71.2.17.2.21
--- php-src/ext/spl/spl_array.c:1.71.2.17.2.20 Sat Oct 18 09:33:21 2008
+++ php-src/ext/spl/spl_array.c Sun Oct 19 18:00:42 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_array.c,v 1.71.2.17.2.20 2008/10/18 09:33:21 tony2001 Exp $ */
+/* $Id: spl_array.c,v 1.71.2.17.2.21 2008/10/19 18:00:42 colder Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -910,9 +910,7 @@
spl_array_object *intern;
zval **array;
long ar_flags = 0;
- char *class_name;
- int class_name_len;
- zend_class_entry ** pce_get_iterator;
+ zend_class_entry * ce_get_iterator = spl_ce_Iterator;
if (ZEND_NUM_ARGS() == 0) {
return; /* nothing to do */
@@ -921,7 +919,7 @@
intern = (spl_array_object*)zend_object_store_get_object(object
TSRMLS_CC);
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|ls", &array,
&ar_flags, &class_name, &class_name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|lC", &array,
&ar_flags, &ce_get_iterator) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
}
@@ -931,12 +929,7 @@
}
if (ZEND_NUM_ARGS() > 2) {
- if (zend_lookup_class(class_name, class_name_len,
&pce_get_iterator TSRMLS_CC) == FAILURE) {
- zend_throw_exception(spl_ce_InvalidArgumentException,
"A class that implements Iterator must be specified", 0 TSRMLS_CC);
- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
- return;
- }
- intern->ce_get_iterator = *pce_get_iterator;
+ intern->ce_get_iterator = ce_get_iterator;
}
ar_flags &= ~SPL_ARRAY_INT_MASK;
@@ -989,21 +982,14 @@
{
zval *object = getThis();
spl_array_object *intern =
(spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
- char *class_name;
- int class_name_len;
- zend_class_entry ** pce_get_iterator;
+ zend_class_entry * ce_get_iterator = spl_ce_Iterator;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &class_name,
&class_name_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C",
&ce_get_iterator) == FAILURE) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
return;
}
- if (zend_lookup_class(class_name, class_name_len, &pce_get_iterator
TSRMLS_CC) == FAILURE) {
- zend_throw_exception(spl_ce_InvalidArgumentException, "A class
that implements Iterator must be specified", 0 TSRMLS_CC);
- php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
- return;
- }
- intern->ce_get_iterator = *pce_get_iterator;
+ intern->ce_get_iterator = ce_get_iterator;
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/arrayObject___construct_error1.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/spl/tests/arrayObject___construct_error1.phpt
diff -u php-src/ext/spl/tests/arrayObject___construct_error1.phpt:1.1.2.1
php-src/ext/spl/tests/arrayObject___construct_error1.phpt:1.1.2.2
--- php-src/ext/spl/tests/arrayObject___construct_error1.phpt:1.1.2.1 Fri Oct
17 14:26:36 2008
+++ php-src/ext/spl/tests/arrayObject___construct_error1.phpt Sun Oct 19
18:00:42 2008
@@ -1,7 +1,5 @@
--TEST--
SPL: ArrayObject::__construct with bad iterator.
---XFAIL--
-See bug http://bugs.php.net/bug.php?id=46317
--FILE--
<?php
echo "Bad iterator type:\n";
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt?r1=1.1.2.1&r2=1.1.2.2&diff_format=u
Index: php-src/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt
diff -u php-src/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt:1.1.2.1
php-src/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt:1.1.2.2
--- php-src/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt:1.1.2.1
Fri Oct 17 14:26:35 2008
+++ php-src/ext/spl/tests/arrayObject_setIteratorClass_error1.phpt Sun Oct
19 18:00:42 2008
@@ -1,7 +1,5 @@
--TEST--
SPL: ArrayObject::setIteratorClass with bad iterator class.
---XFAIL--
-See bug http://bugs.php.net/bug.php?id=46317
--FILE--
<?php
try {
@@ -56,4 +54,4 @@
b=>2
c=>3
string(113) "ArrayObject::__construct() expects parameter 3 to be a class name
derived from Iterator, 'nonExistentClass' given"
-string(105) "ArrayObject::__construct() expects parameter 3 to be a class name
derived from Iterator, 'stdClass' given"
\ No newline at end of file
+string(105) "ArrayObject::__construct() expects parameter 3 to be a class name
derived from Iterator, 'stdClass' given"
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php