X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=php_http_message.c;h=f391d5fd989019a71c962aa80b18dbb265fcfc43;hb=1f934bf6f8bf9343eac1fdc7fdba5959b8d062a1;hp=b32a8226f19f889425e5fd3f4438fad3da5a7fac;hpb=03f11ce599fa5a89148d588caf6ccec7f939e9d4;p=m6w6%2Fext-http diff --git a/php_http_message.c b/php_http_message.c index b32a822..f391d5f 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -20,7 +20,7 @@ zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable /* advance message */ if (!old || old->type || zend_hash_num_elements(&old->hdrs)) { - (*message) = php_http_message_init(NULL, 0, NULL TSRMLS_CC); + (*message) = php_http_message_init(NULL, 0, NULL); (*message)->parent = old; if (headers) { (*headers) = &((*message)->hdrs); @@ -498,6 +498,11 @@ static HashTable *php_http_message_object_get_props(zval *object); static zend_object_handlers php_http_message_object_handlers; static HashTable php_http_message_object_prophandlers; +static void php_http_message_object_prophandler_hash_dtor(zval *pData) +{ + pefree(Z_PTR_P(pData), 1); +} + typedef void (*php_http_message_object_prophandler_func_t)(php_http_message_object_t *o, zval *v); typedef struct php_http_message_object_prophandler { @@ -854,15 +859,18 @@ static zval *php_http_message_object_read_prop(zval *object, zval *member, int t PHP_HTTP_MESSAGE_OBJECT_INIT(obj); + /* 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_get_prophandler(member_name))) { + zval_dtor(return_value); + 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); } - } else { - zend_get_std_object_handlers()->read_property(object, member, type, cache_slot, return_value); } zend_string_release(member_name); @@ -1012,7 +1020,7 @@ static PHP_METHOD(HttpMessage, __construct) msg = php_http_message_parse(NULL, zs_msg->val, zs_msg->len, greedy); if (!msg && !EG(exception)) { - php_http_throw(bad_message, "Could not parse message: %.*s", MIN(25, zs_msg->len), zs_msg->len); + php_http_throw(bad_message, "Could not parse message: %.*s", MIN(25, zs_msg->len), zs_msg->val); } zend_string_release(zs_msg); } @@ -1429,7 +1437,7 @@ ZEND_END_ARG_INFO(); static PHP_METHOD(HttpMessage, setResponseStatus) { char *status; - int status_len; + size_t status_len; php_http_message_object_t *obj; php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &status, &status_len), invalid_arg, return); @@ -1766,6 +1774,7 @@ static PHP_METHOD(HttpMessage, isMultipart) } if (zboundary && boundary) { + ZVAL_DEREF(zboundary); zval_dtor(zboundary); ZVAL_STR(zboundary, php_http_cs2zs(boundary, strlen(boundary))); } @@ -1954,7 +1963,7 @@ PHP_MINIT_FUNCTION(http_message) memcpy(&php_http_message_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_http_message_object_handlers.offset = XtOffsetOf(php_http_message_object_t, zo); php_http_message_object_handlers.clone_obj = php_http_message_object_clone; - php_http_message_object_handlers.dtor_obj = php_http_message_object_free; + php_http_message_object_handlers.free_obj = php_http_message_object_free; php_http_message_object_handlers.read_property = php_http_message_object_read_prop; php_http_message_object_handlers.write_property = php_http_message_object_write_prop; php_http_message_object_handlers.get_properties = php_http_message_object_get_props; @@ -1962,7 +1971,7 @@ PHP_MINIT_FUNCTION(http_message) zend_class_implements(php_http_message_class_entry, 3, spl_ce_Countable, zend_ce_serializable, zend_ce_iterator); - zend_hash_init(&php_http_message_object_prophandlers, 9, NULL, NULL, 1); + zend_hash_init(&php_http_message_object_prophandlers, 9, NULL, php_http_message_object_prophandler_hash_dtor, 1); zend_declare_property_long(php_http_message_class_entry, ZEND_STRL("type"), PHP_HTTP_NONE, ZEND_ACC_PROTECTED); php_http_message_object_add_prophandler(ZEND_STRL("type"), php_http_message_object_prophandler_get_type, php_http_message_object_prophandler_set_type); zend_declare_property_null(php_http_message_class_entry, ZEND_STRL("body"), ZEND_ACC_PROTECTED);