kalle Wed Jul 1 18:45:32 2009 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/com_dotnet/tests bug45280.phpt
Modified files:
/php-src/ext/reflection php_reflection.c
Log:
Fixed #45280 (Reflection of instantiated COM classes causes PHP to crash)
(Paul Richards, Kalle)
http://cvs.php.net/viewvc.cgi/php-src/ext/reflection/php_reflection.c?r1=1.164.2.33.2.57&r2=1.164.2.33.2.58&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.57
php-src/ext/reflection/php_reflection.c:1.164.2.33.2.58
--- php-src/ext/reflection/php_reflection.c:1.164.2.33.2.57 Thu May 21
16:05:11 2009
+++ php-src/ext/reflection/php_reflection.c Wed Jul 1 18:45:32 2009
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_reflection.c,v 1.164.2.33.2.57 2009/05/21 16:05:11 lbarnaud Exp $
*/
+/* $Id: php_reflection.c,v 1.164.2.33.2.58 2009/07/01 18:45:32 kalle Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -481,23 +481,25 @@
string_init(&dyn);
count = 0;
- zend_hash_internal_pointer_reset_ex(properties, &pos);
+ 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) {
- char *prop_name;
- uint prop_name_size;
- ulong index;
-
- if (zend_hash_get_current_key_ex(properties,
&prop_name, &prop_name_size, &index, 1, &pos) == HASH_KEY_IS_STRING) {
- if (prop_name_size && prop_name[0]) { /* skip
all private and protected properties */
- if
(!zend_hash_quick_exists(&ce->properties_info, prop_name, prop_name_size,
zend_get_hash_value(prop_name, prop_name_size))) {
+ while (zend_hash_get_current_data_ex(properties, (void
**) &prop, &pos) == SUCCESS) {
+ char *prop_name;
+ uint prop_name_size;
+ ulong index;
+
+ if (zend_hash_get_current_key_ex(properties,
&prop_name, &prop_name_size, &index, 1, &pos) == HASH_KEY_IS_STRING) {
+ if (prop_name_size && prop_name[0]) {
/* skip all private and protected properties */
+ if
(!zend_hash_quick_exists(&ce->properties_info, prop_name, prop_name_size,
zend_get_hash_value(prop_name, prop_name_size))) {
count++;
- _property_string(&dyn, NULL,
prop_name, sub_indent.string TSRMLS_CC);
+ _property_string(&dyn,
NULL, prop_name, sub_indent.string TSRMLS_CC);
+ }
}
+ efree(prop_name);
}
- efree(prop_name);
+ 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);
@@ -4952,7 +4954,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.57 2009/05/21 16:05:11 lbarnaud Exp $");
+ php_info_print_table_row(2, "Version", "$Id: php_reflection.c,v
1.164.2.33.2.58 2009/07/01 18:45:32 kalle Exp $");
php_info_print_table_end();
} /* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/com_dotnet/tests/bug45280.phpt?view=markup&rev=1.1
Index: php-src/ext/com_dotnet/tests/bug45280.phpt
+++ php-src/ext/com_dotnet/tests/bug45280.phpt
--TEST--
Bug #45280 (Reflection of instantiated COM classes causes PHP to crash)
--SKIPIF--
<?php
if (!extension_loaded("reflection")){ echo "skip, no reflection support
present"; }
if (!extension_loaded("com_dotnet")){ echo "skip COM/.Net support not present";
}
?>
--FILE--
<?php
$dict = new COM("Scripting.Dictionary");
ob_start();
ReflectionObject::export($dict);
ob_get_clean();
echo 'done';
?>
--EXPECT--
done
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php