From: Kalle Sommer Nielsen Date: Wed, 1 Jul 2009 18:44:16 +0000 (+0000) Subject: Fixed #45280 (Reflection of instantiated COM classes causes PHP to crash) (Paul Richa... X-Git-Tag: php-5.4.0alpha1~191^2~3192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3aae5bc9a1b84104f2ae43da78cdd10cdcc6e15d;p=php Fixed #45280 (Reflection of instantiated COM classes causes PHP to crash) (Paul Richards, Kalle) --- diff --git a/ext/com_dotnet/tests/bug45280.phpt b/ext/com_dotnet/tests/bug45280.phpt new file mode 100644 index 0000000000..a1f7e18f73 --- /dev/null +++ b/ext/com_dotnet/tests/bug45280.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #45280 (Reflection of instantiated COM classes causes PHP to crash) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +done diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 6208aaa536..ce48aba003 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -531,23 +531,25 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in string_init(&dyn); count = 0; - zend_hash_internal_pointer_reset_ex(properties, &pos); - - while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) { - zstr prop_name; - uint prop_name_size; - zend_uchar prop_type; - ulong index; - - if ((prop_type = zend_hash_get_current_key_ex(properties, &prop_name, &prop_name_size, &index, 0, &pos)) == HASH_KEY_IS_UNICODE) { - if (prop_name_size && prop_name.u[0]) { /* skip all private and protected properties */ - if (!zend_u_hash_exists(&ce->properties_info, prop_type, prop_name, prop_name_size)) { - count++; - _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC); + if (properties && zend_hash_num_elements(properties)) { + zend_hash_internal_pointer_reset_ex(properties, &pos); + + while (zend_hash_get_current_data_ex(properties, (void **) &prop, &pos) == SUCCESS) { + zstr prop_name; + uint prop_name_size; + zend_uchar prop_type; + ulong index; + + if ((prop_type = zend_hash_get_current_key_ex(properties, &prop_name, &prop_name_size, &index, 0, &pos)) == HASH_KEY_IS_UNICODE) { + if (prop_name_size && prop_name.u[0]) { /* skip all private and protected properties */ + if (!zend_u_hash_exists(&ce->properties_info, prop_type, prop_name, prop_name_size)) { + count++; + _property_string(&dyn, NULL, prop_name, sub_indent.string TSRMLS_CC); + } } } + zend_hash_move_forward_ex(properties, &pos); } - zend_hash_move_forward_ex(properties, &pos); } string_printf(str, "\n%s - Dynamic properties [%d] {\n", indent, count);