zval h, *h_loc = NULL, *h_con = NULL, *h_cl, *h_cr, *h_te, *h_ce;
if ((h_te = php_http_message_header(*message, ZEND_STRL("Transfer-Encoding")))) {
+ Z_TRY_ADDREF_P(h_te);
zend_hash_str_update(&(*message)->hdrs, "X-Original-Transfer-Encoding", lenof("X-Original-Transfer-Encoding"), h_te);
zend_hash_str_del(&(*message)->hdrs, "Transfer-Encoding", lenof("Transfer-Encoding"));
}
if ((h_cl = php_http_message_header(*message, ZEND_STRL("Content-Length")))) {
+ Z_TRY_ADDREF_P(h_cl);
zend_hash_str_update(&(*message)->hdrs, "X-Original-Content-Length", lenof("X-Original-Content-Length"), h_cl);
}
if ((h_cr = php_http_message_header(*message, ZEND_STRL("Content-Range")))) {
+ Z_TRY_ADDREF_P(h_cr);
zend_hash_str_update(&(*message)->hdrs, "X-Original-Content-Range", sizeof("X-Original-Content-Range"), h_cr);
zend_hash_str_del(&(*message)->hdrs, "Content-Range", lenof("Content-Range"));
}
} else {
parser->inflate = php_http_encoding_stream_init(NULL, php_http_encoding_stream_get_inflate_ops(), 0);
}
+ Z_TRY_ADDREF_P(h_ce);
zend_hash_str_update(&(*message)->hdrs, "X-Original-Content-Encoding", lenof("X-Original-Content-Encoding"), h_ce);
zend_hash_str_del(&(*message)->hdrs, "Content-Encoding", lenof("Content-Encoding"));
- } else {
- zval_ptr_dtor(h_ce);
}
}
{
if (Z_TYPE_P(zv) == IS_STRING) {
size_t len = Z_STRLEN_P(zv);
- zend_string *stripped = php_addcslashes(Z_STRVAL_P(zv), Z_STRLEN_P(zv), 1,
+ zend_string *stripped = php_addcslashes(Z_STRVAL_P(zv), Z_STRLEN_P(zv), 0,
ZEND_STRL("\0..\37\173\\\""));
if (len != stripped->len || strpbrk(stripped->val, "()<>@,;:\"[]?={} ")) {
zvalue = tmp;
} else if (zvalue == zparam) {
continue;
+ } else {
+ zvalue = zparam;
}
- zvalue = zparam;
}
if (Z_TYPE_P(zvalue) == IS_ARRAY) {
php_http_params_token_t **php_http_params_separator_init(zval *zv)
{
- zval *sep;
+ zval *sep, ztmp;
php_http_params_token_t **ret, **tmp;
if (!zv) {
return NULL;
}
- SEPARATE_ZVAL(zv);
+ ZVAL_DUP(&ztmp, zv);
+ zv = &ztmp;
convert_to_array(zv);
+
ret = ecalloc(zend_hash_num_elements(Z_ARRVAL_P(zv)) + 1, sizeof(*ret));
tmp = ret;
zend_string_release(zs);
}
ZEND_HASH_FOREACH_END();
- zval_ptr_dtor(zv);
+
+ zval_ptr_dtor(&ztmp);
*tmp = NULL;
return ret;
default:
zs = zval_get_string(zparams);
if (zs->len) {
+ zval tmp;
+
php_http_params_opts_t opts = {
{zs->val, zs->len},
php_http_params_separator_init(zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("param_sep"), 0)),
{{0}}, flags
};
- array_init(zparams);
- php_http_params_parse(Z_ARRVAL_P(zparams), &opts);
- zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
+ array_init(&tmp);
+ php_http_params_parse(Z_ARRVAL(tmp), &opts);
+ zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), &tmp);
+ zval_ptr_dtor(&tmp);
php_http_params_separator_free(opts.param);
php_http_params_separator_free(opts.arg);
php_http_params_separator_free(opts.val);
}
+ zend_string_release(zs);
break;
}
} else {
- array_init(zparams);
- zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
+ zval tmp;
+
+ array_init(&tmp);
+ zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), &tmp);
+ zval_ptr_dtor(&tmp);
}
}
zend_restore_error_handling(&zeh);
if (Z_TYPE_P(zparams) == IS_ARRAY) {
zend_symtable_del(Z_ARRVAL_P(zparams), name);
- zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
}
}
}
zparams = zend_read_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), 0);
- SEPARATE_ZVAL(zparams);
convert_to_array(zparams);
if (name->len) {
if (Z_TYPE_P(nvalue) == IS_ARRAY) {
- zval *new_zparam;
-
if ((zparam = zend_symtable_find(Z_ARRVAL_P(zparams), name))) {
- new_zparam = zparam;
- SEPARATE_ZVAL(new_zparam);
- convert_to_array(new_zparam);
- array_join(Z_ARRVAL_P(nvalue), Z_ARRVAL_P(new_zparam), 0, 0);
+ convert_to_array(zparam);
+ array_join(Z_ARRVAL_P(nvalue), Z_ARRVAL_P(zparam), 0, 0);
} else {
- new_zparam = nvalue;
- Z_TRY_ADDREF_P(new_zparam);
+ Z_TRY_ADDREF_P(nvalue);
+ add_assoc_zval_ex(zparams, name->val, name->len, nvalue);
}
- add_assoc_zval_ex(zparams, name->val, name->len, new_zparam);
} else {
zval tmp;
if ((zparam = zend_symtable_find(Z_ARRVAL_P(zparams), name))) {
- tmp = *zparam;
- SEPARATE_ZVAL(&tmp);
+ ZVAL_DUP(&tmp, zparam);
convert_to_array(&tmp);
} else {
array_init(&tmp);
add_assoc_zval_ex(zparams, zs->val, zs->len, &arr);
zend_string_release(zs);
}
-
- zend_update_property(php_http_params_class_entry, getThis(), ZEND_STRL("params"), zparams);
- zval_ptr_dtor(zparams);
}
static zend_function_entry php_http_params_methods[] = {