X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_message.c;h=caf9ee82786347b7f4fb491ae928e5d22dc3e995;hb=c01b22de1d6070dcd589cf203de4f002e90eff55;hp=f391d5fd989019a71c962aa80b18dbb265fcfc43;hpb=1f934bf6f8bf9343eac1fdc7fdba5959b8d062a1;p=m6w6%2Fext-http diff --git a/php_http_message.c b/php_http_message.c index f391d5f..caf9ee8 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -688,7 +688,7 @@ void php_http_message_object_reverse(zval *zmsg, zval *return_value) /* add ref, because we previously have not been a parent message */ Z_ADDREF_P(zmsg); - RETVAL_OBJ(&objects[last]->zo); + RETVAL_OBJECT(&objects[last]->zo, 1); efree(objects); } else { @@ -806,6 +806,8 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce, o->message = msg; if (msg->parent) { o->parent = php_http_message_object_new_ex(ce, msg->parent); + /* not assigned to any zval, so refcount is 0 */ + --GC_REFCOUNT(&o->parent->zo); } o->body = php_http_message_body_object_new_ex(php_http_message_body_class_entry, php_http_message_body_init(&msg->body, NULL)); } @@ -851,26 +853,26 @@ void php_http_message_object_free(zend_object *object) zend_object_std_dtor(object); } -static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *return_value) +static zval *php_http_message_object_read_prop(zval *object, zval *member, int type, void **cache_slot, zval *tmp) { - php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object); - php_http_message_object_prophandler_t *handler; + zval *return_value; zend_string *member_name = zval_get_string(member); + php_http_message_object_prophandler_t *handler = php_http_message_object_get_prophandler(member_name); - PHP_HTTP_MESSAGE_OBJECT_INIT(obj); + if (!handler || type == BP_VAR_R || type == BP_VAR_IS) { + return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, tmp); - /* supplied retun_value lives on the stack of zend_read_property! */ - return_value = zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, return_value); + if (handler) { + php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, object); - if ((handler = php_http_message_object_get_prophandler(member_name))) { - zval_dtor(return_value); + PHP_HTTP_MESSAGE_OBJECT_INIT(obj); + handler->read(obj, tmp); - if (type == BP_VAR_R) { - handler->read(obj, return_value); - } else { - php_property_proxy_t *proxy = php_property_proxy_init(object, member_name); - RETVAL_OBJ(&php_property_proxy_object_new_ex(php_property_proxy_get_class_entry(), proxy)->zo); + zval_ptr_dtor(return_value); + ZVAL_COPY_VALUE(return_value, tmp); } + } else { + return_value = php_property_proxy_zval(object, member_name); } zend_string_release(member_name);