tony2001 Wed Jul 26 08:03:49 2006 UTC Added files: (Branch: PHP_5_2) /php-src/ext/reflection/tests bug38217.phpt
Modified files: /php-src/ext/reflection php_reflection.c /php-src NEWS Log: MFH: fix bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too much memory) http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.17&r2=1.164.2.33.2.18&diff_format=u Index: php-src/ext/reflection/php_reflection.c diff -u php-src/ext/reflection/php_reflection.c:1.164.2.33.2.17 php-src/ext/reflection/php_reflection.c:1.164.2.33.2.18 --- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.17 Tue Jul 25 14:44:53 2006 +++ php-src/ext/reflection/php_reflection.c Wed Jul 26 08:03:48 2006 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reflection.c,v 1.164.2.33.2.17 2006/07/25 14:44:53 mike Exp $ */ +/* $Id: php_reflection.c,v 1.164.2.33.2.18 2006/07/26 08:03:48 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -3394,7 +3394,7 @@ zval *retval_ptr; reflection_object *intern; zend_class_entry *ce; - int argc; + int argc = 0; HashTable *args; @@ -3404,11 +3404,13 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|h", &args) == FAILURE) { return; } - argc = args->nNumOfElements; + if (ZEND_NUM_ARGS() > 0) { + argc = args->nNumOfElements; + } /* Run the constructor if there is one */ if (ce->constructor) { - zval ***params; + zval ***params = NULL; zend_fcall_info fci; zend_fcall_info_cache fcc; @@ -3416,10 +3418,12 @@ zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name); return; } - - params = safe_emalloc(sizeof(zval **), argc, 0); - zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); - params -= argc; + + if (argc) { + params = safe_emalloc(sizeof(zval **), argc, 0); + zend_hash_apply_with_argument(args, (apply_func_arg_t)_zval_array_to_c_array, ¶ms TSRMLS_CC); + params -= argc; + } object_init_ex(return_value, ce); @@ -3439,7 +3443,9 @@ fcc.object_pp = &return_value; if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) { - efree(params); + if (params) { + efree(params); + } zval_ptr_dtor(&retval_ptr); zend_error(E_WARNING, "Invocation of %s's constructor failed", ce->name); RETURN_NULL(); @@ -3447,7 +3453,9 @@ if (retval_ptr) { zval_ptr_dtor(&retval_ptr); } - efree(params); + if (params) { + efree(params); + } } else if (!ZEND_NUM_ARGS()) { object_init_ex(return_value, ce); } else { @@ -4792,7 +4800,7 @@ php_info_print_table_start(); php_info_print_table_header(2, "Reflection", "enabled"); - php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33.2.17 2006/07/25 14:44:53 mike Exp $"); + php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v 1.164.2.33.2.18 2006/07/26 08:03:48 tony2001 Exp $"); php_info_print_table_end(); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.146&r2=1.2027.2.547.2.147&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.146 php-src/NEWS:1.2027.2.547.2.147 --- php-src/NEWS:1.2027.2.547.2.146 Tue Jul 25 14:06:51 2006 +++ php-src/NEWS Wed Jul 26 08:03:48 2006 @@ -9,6 +9,8 @@ . ext/filepro (Derick, Tony) . ext/hwapi (Derick, Tony) +- Fixed bug #38217 (ReflectionClass::newInstanceArgs() tries to allocate too + much memory). (Tony) - Fixed bug #38194 (ReflectionClass::isSubclassOf() returns TRUE for the class itself). (Ilia) - Fixed bug #38132 (ReflectionClass::getStaticProperties() retains \0 in key http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/tests/bug38217.phpt?view=markup&rev=1.1 Index: php-src/ext/reflection/tests/bug38217.phpt +++ php-src/ext/reflection/tests/bug38217.phpt -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php