From c62b08650b335221386e5858bf24334e7d61c8b5 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Thu, 27 Jul 2006 09:19:26 +0000 Subject: [PATCH] Fix usage of uninitialized value and unicode support --- ext/reflection/php_reflection.c | 9 +++++---- ext/reflection/tests/bug38132.phpt | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index 6c8045b1fc2..e75cadea1bf 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -2645,8 +2645,8 @@ ZEND_METHOD(reflection_class, getStaticProperties) { reflection_object *intern; zend_class_entry *ce; - HashPosition pos; - zval **value; + HashPosition pos; + zval **value; METHOD_NOTSTATIC_NUMPARAMS(reflection_class_ptr, 0); GET_REFLECTION_OBJECT_PTR(ce); @@ -2663,13 +2663,14 @@ ZEND_METHOD(reflection_class, getStaticProperties) if (zend_hash_get_current_key_ex(CE_STATIC_MEMBERS(ce), &key, &key_len, &num_index, 0, &pos) != FAILURE) { zstr prop_name, class_name; - int prop_name_len = UG(unicode) ? u_strlen(prop_name.u) : strlen(prop_name.s); + int prop_name_len; zend_u_unmangle_property_name(UG(unicode)?IS_UNICODE:IS_STRING, key, key_len-1, &class_name, &prop_name); + prop_name_len = UG(unicode) ? u_strlen(prop_name.u) : strlen(prop_name.s); zval_add_ref(value); - zend_u_hash_update(Z_ARRVAL_P(return_value), UG(unicode)?IS_UNICODE:IS_STRING, prop_name, prop_name_len, value, sizeof(zval *), NULL); + zend_u_hash_update(Z_ARRVAL_P(return_value), UG(unicode)?IS_UNICODE:IS_STRING, prop_name, prop_name_len+1, value, sizeof(zval *), NULL); } zend_hash_move_forward_ex(CE_STATIC_MEMBERS(ce), &pos); } diff --git a/ext/reflection/tests/bug38132.phpt b/ext/reflection/tests/bug38132.phpt index aeb6246b89f..80df58d4f5e 100755 --- a/ext/reflection/tests/bug38132.phpt +++ b/ext/reflection/tests/bug38132.phpt @@ -32,3 +32,19 @@ array(2) { bool(false) bool(false) bool(true) +--UEXPECT-- +array(2) { + [u"bar"]=> + unicode(3) "baz" + [u"a"]=> + unicode(1) "a" +} +array(2) { + [0]=> + unicode(3) "bar" + [1]=> + unicode(1) "a" +} +bool(false) +bool(false) +bool(true)