]> granicus.if.org Git - php/commitdiff
Fixed #45280 (Reflection of instantiated COM classes causes PHP to crash) (Paul Richa...
authorKalle Sommer Nielsen <kalle@php.net>
Wed, 1 Jul 2009 18:45:32 +0000 (18:45 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Wed, 1 Jul 2009 18:45:32 +0000 (18:45 +0000)
ext/com_dotnet/tests/bug45280.phpt [new file with mode: 0644]
ext/reflection/php_reflection.c

diff --git a/ext/com_dotnet/tests/bug45280.phpt b/ext/com_dotnet/tests/bug45280.phpt
new file mode 100644 (file)
index 0000000..a1f7e18
--- /dev/null
@@ -0,0 +1,19 @@
+--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
index f11639a61543672c97c683049df5817e7716ac68..6e1182723ba1ee531b75a8dc71253825b2d9c95b 100644 (file)
@@ -481,23 +481,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);
+               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;
+                       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))) {
+                               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);