mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Avoid unnecessary reference-counting on strings.
This commit is contained in:
parent
ce18738a30
commit
ccc12b82da
10
Zend/zend.c
10
Zend/zend.c
@ -322,14 +322,15 @@ ZEND_API int zend_make_printable_zval(zval *expr, zval *expr_copy) /* {{{ */
|
||||
|
||||
ZEND_API size_t zend_print_zval(zval *expr, int indent) /* {{{ */
|
||||
{
|
||||
zend_string *str = zval_get_string(expr);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(expr, &tmp_str);
|
||||
size_t len = ZSTR_LEN(str);
|
||||
|
||||
if (len != 0) {
|
||||
zend_write(ZSTR_VAL(str), len);
|
||||
}
|
||||
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return len;
|
||||
}
|
||||
/* }}} */
|
||||
@ -436,9 +437,12 @@ static void zend_print_zval_r_to_buf(smart_str *buf, zval *expr, int indent) /*
|
||||
case IS_REFERENCE:
|
||||
zend_print_zval_r_to_buf(buf, Z_REFVAL_P(expr), indent);
|
||||
break;
|
||||
case IS_STRING:
|
||||
smart_str_append(buf, Z_STR_P(expr));
|
||||
break;
|
||||
default:
|
||||
{
|
||||
zend_string *str = zval_get_string(expr);
|
||||
zend_string *str = zval_get_string_func(expr);
|
||||
smart_str_append(buf, str);
|
||||
zend_string_release(str);
|
||||
}
|
||||
|
@ -198,7 +198,8 @@ ZEND_METHOD(Closure, bind)
|
||||
} else if (Z_TYPE_P(scope_arg) == IS_NULL) {
|
||||
ce = NULL;
|
||||
} else {
|
||||
zend_string *class_name = zval_get_string(scope_arg);
|
||||
zend_string *tmp_class_name;
|
||||
zend_string *class_name = zval_get_tmp_string(scope_arg, &tmp_class_name);
|
||||
if (zend_string_equals_literal(class_name, "static")) {
|
||||
ce = closure->func.common.scope;
|
||||
} else if ((ce = zend_lookup_class_ex(class_name, NULL, 1)) == NULL) {
|
||||
@ -206,7 +207,7 @@ ZEND_METHOD(Closure, bind)
|
||||
zend_string_release(class_name);
|
||||
RETURN_NULL();
|
||||
}
|
||||
zend_string_release(class_name);
|
||||
zend_tmp_string_release(tmp_class_name);
|
||||
}
|
||||
} else { /* scope argument not given; do not change the scope by default */
|
||||
ce = closure->func.common.scope;
|
||||
|
@ -1242,7 +1242,7 @@ static zend_never_inline void zend_assign_to_string_offset(zval *str, zval *dim,
|
||||
|
||||
if (Z_TYPE_P(value) != IS_STRING) {
|
||||
/* Convert to string, just the time to pick the 1st byte */
|
||||
zend_string *tmp = zval_get_string(value);
|
||||
zend_string *tmp = zval_get_string_func(value);
|
||||
|
||||
string_len = ZSTR_LEN(tmp);
|
||||
c = (zend_uchar)ZSTR_VAL(tmp)[0];
|
||||
@ -1934,19 +1934,19 @@ use_read_property:
|
||||
static zend_always_inline zval* zend_fetch_static_property_address(zval *varname, zend_uchar varname_type, znode_op op2, zend_uchar op2_type, int type EXECUTE_DATA_DC OPLINE_DC)
|
||||
{
|
||||
zval *retval;
|
||||
zend_string *name;
|
||||
zend_string *name, *tmp_name;
|
||||
zend_class_entry *ce;
|
||||
|
||||
if (varname_type == IS_CONST) {
|
||||
name = Z_STR_P(varname);
|
||||
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
|
||||
name = Z_STR_P(varname);
|
||||
zend_string_addref(name);
|
||||
tmp_name = NULL;
|
||||
} else {
|
||||
if (varname_type == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
|
||||
zval_undefined_cv(EX(opline)->op1.var EXECUTE_DATA_CC);
|
||||
}
|
||||
name = zval_get_string(varname);
|
||||
name = zval_get_tmp_string(varname, &tmp_name);
|
||||
}
|
||||
|
||||
if (op2_type == IS_CONST) {
|
||||
@ -1969,7 +1969,7 @@ static zend_always_inline zval* zend_fetch_static_property_address(zval *varname
|
||||
ce = zend_fetch_class_by_name(Z_STR_P(class_name), class_name + 1, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
|
||||
if (UNEXPECTED(ce == NULL)) {
|
||||
if (varname_type != IS_CONST) {
|
||||
zend_string_release(name);
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -1981,7 +1981,7 @@ static zend_always_inline zval* zend_fetch_static_property_address(zval *varname
|
||||
ce = zend_fetch_class(NULL, op2.num);
|
||||
if (UNEXPECTED(ce == NULL)) {
|
||||
if (varname_type != IS_CONST) {
|
||||
zend_string_release(name);
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -2007,7 +2007,7 @@ static zend_always_inline zval* zend_fetch_static_property_address(zval *varname
|
||||
retval = zend_std_get_static_property(ce, name, type == BP_VAR_IS);
|
||||
|
||||
if (varname_type != IS_CONST) {
|
||||
zend_string_release(name);
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
|
||||
if (UNEXPECTED(retval == NULL)) {
|
||||
|
@ -520,9 +520,10 @@ static ZEND_COLD zend_string *zend_get_function_declaration(const zend_function
|
||||
smart_str_appends(&str, "<expression>");
|
||||
}
|
||||
} else {
|
||||
zend_string *zv_str = zval_get_string(zv);
|
||||
zend_string *tmp_zv_str;
|
||||
zend_string *zv_str = zval_get_tmp_string(zv, &tmp_zv_str);
|
||||
smart_str_append(&str, zv_str);
|
||||
zend_string_release(zv_str);
|
||||
zend_tmp_string_release(tmp_zv_str);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -111,13 +111,14 @@ static void zend_ini_add_string(zval *result, zval *op1, zval *op2)
|
||||
int length, op1_len;
|
||||
|
||||
if (Z_TYPE_P(op1) != IS_STRING) {
|
||||
zend_string *str = zval_get_string(op1);
|
||||
/* ZEND_ASSERT(!Z_REFCOUNTED_P(op1)); */
|
||||
if (ZEND_SYSTEM_INI) {
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(op1, &tmp_str);
|
||||
ZVAL_PSTRINGL(op1, ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
} else {
|
||||
ZVAL_STR(op1, str);
|
||||
ZVAL_STR(op1, zval_get_string_func(op1));
|
||||
}
|
||||
}
|
||||
op1_len = (int)Z_STRLEN_P(op1);
|
||||
|
@ -886,16 +886,12 @@ static int zend_std_has_dimension(zval *object, zval *offset, int check_empty) /
|
||||
static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */
|
||||
{
|
||||
zend_object *zobj;
|
||||
zend_string *name;
|
||||
zend_string *name, *tmp_name;
|
||||
zval *retval = NULL;
|
||||
uintptr_t property_offset;
|
||||
|
||||
zobj = Z_OBJ_P(object);
|
||||
if (EXPECTED(Z_TYPE_P(member) == IS_STRING)) {
|
||||
name = Z_STR_P(member);
|
||||
} else {
|
||||
name = zval_get_string(member);
|
||||
}
|
||||
name = zval_get_tmp_string(member, &tmp_name);
|
||||
|
||||
#if DEBUG_OBJECT_HANDLERS
|
||||
fprintf(stderr, "Ptr object #%d property: %s\n", Z_OBJ_HANDLE_P(object), ZSTR_VAL(name));
|
||||
@ -928,9 +924,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
|
||||
zobj->properties = zend_array_dup(zobj->properties);
|
||||
}
|
||||
if (EXPECTED((retval = zend_hash_find(zobj->properties, name)) != NULL)) {
|
||||
if (UNEXPECTED(Z_TYPE_P(member) != IS_STRING)) {
|
||||
zend_string_release(name);
|
||||
}
|
||||
zend_tmp_string_release(tmp_name);
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
@ -948,9 +942,7 @@ static zval *zend_std_get_property_ptr_ptr(zval *object, zval *member, int type,
|
||||
}
|
||||
}
|
||||
|
||||
if (UNEXPECTED(Z_TYPE_P(member) != IS_STRING)) {
|
||||
zend_string_release(name);
|
||||
}
|
||||
zend_tmp_string_release(tmp_name);
|
||||
return retval;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1809,8 +1809,9 @@ ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /
|
||||
|
||||
ZEND_API int ZEND_FASTCALL string_compare_function_ex(zval *op1, zval *op2, zend_bool case_insensitive) /* {{{ */
|
||||
{
|
||||
zend_string *str1 = zval_get_string(op1);
|
||||
zend_string *str2 = zval_get_string(op2);
|
||||
zend_string *tmp_str1, *tmp_str2;
|
||||
zend_string *str1 = zval_get_tmp_string(op1, &tmp_str1);
|
||||
zend_string *str2 = zval_get_tmp_string(op2, &tmp_str2);
|
||||
int ret;
|
||||
|
||||
if (case_insensitive) {
|
||||
@ -1819,8 +1820,8 @@ ZEND_API int ZEND_FASTCALL string_compare_function_ex(zval *op1, zval *op2, zend
|
||||
ret = zend_binary_strcmp(ZSTR_VAL(str1), ZSTR_LEN(str1), ZSTR_VAL(str2), ZSTR_LEN(str2));
|
||||
}
|
||||
|
||||
zend_string_release(str1);
|
||||
zend_string_release(str2);
|
||||
zend_tmp_string_release(tmp_str1);
|
||||
zend_tmp_string_release(tmp_str2);
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
@ -1835,12 +1836,13 @@ ZEND_API int ZEND_FASTCALL string_compare_function(zval *op1, zval *op2) /* {{{
|
||||
return zend_binary_strcmp(Z_STRVAL_P(op1), Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
|
||||
}
|
||||
} else {
|
||||
zend_string *str1 = zval_get_string(op1);
|
||||
zend_string *str2 = zval_get_string(op2);
|
||||
zend_string *tmp_str1, *tmp_str2;
|
||||
zend_string *str1 = zval_get_tmp_string(op1, &tmp_str1);
|
||||
zend_string *str2 = zval_get_tmp_string(op2, &tmp_str2);
|
||||
int ret = zend_binary_strcmp(ZSTR_VAL(str1), ZSTR_LEN(str1), ZSTR_VAL(str2), ZSTR_LEN(str2));
|
||||
|
||||
zend_string_release(str1);
|
||||
zend_string_release(str2);
|
||||
zend_tmp_string_release(tmp_str1);
|
||||
zend_tmp_string_release(tmp_str2);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -1856,12 +1858,13 @@ ZEND_API int ZEND_FASTCALL string_case_compare_function(zval *op1, zval *op2) /*
|
||||
return zend_binary_strcasecmp_l(Z_STRVAL_P(op1), Z_STRLEN_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op2));
|
||||
}
|
||||
} else {
|
||||
zend_string *str1 = zval_get_string(op1);
|
||||
zend_string *str2 = zval_get_string(op2);
|
||||
zend_string *tmp_str1, *tmp_str2;
|
||||
zend_string *str1 = zval_get_tmp_string(op1, &tmp_str1);
|
||||
zend_string *str2 = zval_get_tmp_string(op2, &tmp_str2);
|
||||
int ret = zend_binary_strcasecmp_l(ZSTR_VAL(str1), ZSTR_LEN(str1), ZSTR_VAL(str2), ZSTR_LEN(str1));
|
||||
|
||||
zend_string_release(str1);
|
||||
zend_string_release(str2);
|
||||
zend_tmp_string_release(tmp_str1);
|
||||
zend_tmp_string_release(tmp_str2);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@ -1870,12 +1873,13 @@ ZEND_API int ZEND_FASTCALL string_case_compare_function(zval *op1, zval *op2) /*
|
||||
#if HAVE_STRCOLL
|
||||
ZEND_API int ZEND_FASTCALL string_locale_compare_function(zval *op1, zval *op2) /* {{{ */
|
||||
{
|
||||
zend_string *str1 = zval_get_string(op1);
|
||||
zend_string *str2 = zval_get_string(op2);
|
||||
zend_string *tmp_str1, *tmp_str2;
|
||||
zend_string *str1 = zval_get_tmp_string(op1, &tmp_str1);
|
||||
zend_string *str2 = zval_get_tmp_string(op2, &tmp_str2);
|
||||
int ret = strcoll(ZSTR_VAL(str1), ZSTR_VAL(str2));
|
||||
|
||||
zend_string_release(str1);
|
||||
zend_string_release(str2);
|
||||
zend_tmp_string_release(tmp_str1);
|
||||
zend_tmp_string_release(tmp_str2);
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -273,6 +273,20 @@ static zend_always_inline zend_string *zval_get_string(zval *op) {
|
||||
return EXPECTED(Z_TYPE_P(op) == IS_STRING) ? zend_string_copy(Z_STR_P(op)) : zval_get_string_func(op);
|
||||
}
|
||||
|
||||
static zend_always_inline zend_string *zval_get_tmp_string(zval *op, zend_string **tmp) {
|
||||
if (EXPECTED(Z_TYPE_P(op) == IS_STRING)) {
|
||||
*tmp = NULL;
|
||||
return Z_STR_P(op);
|
||||
} else {
|
||||
return *tmp = zval_get_string_func(op);
|
||||
}
|
||||
}
|
||||
static zend_always_inline void zend_tmp_string_release(zend_string *tmp) {
|
||||
if (UNEXPECTED(tmp)) {
|
||||
zend_string_release(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
/* Compatibility macros for 7.2 and below */
|
||||
#define _zval_get_long(op) zval_get_long(op)
|
||||
#define _zval_get_double(op) zval_get_double(op)
|
||||
|
@ -1379,7 +1379,7 @@ ZEND_VM_HELPER(zend_fetch_var_address_helper, CONST|TMPVAR|CV, UNUSED, int type)
|
||||
zend_free_op free_op1;
|
||||
zval *varname;
|
||||
zval *retval;
|
||||
zend_string *name;
|
||||
zend_string *name, *tmp_name;
|
||||
HashTable *target_symbol_table;
|
||||
|
||||
SAVE_OPLINE();
|
||||
@ -1389,12 +1389,12 @@ ZEND_VM_HELPER(zend_fetch_var_address_helper, CONST|TMPVAR|CV, UNUSED, int type)
|
||||
name = Z_STR_P(varname);
|
||||
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
|
||||
name = Z_STR_P(varname);
|
||||
zend_string_addref(name);
|
||||
tmp_name = NULL;
|
||||
} else {
|
||||
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
|
||||
GET_OP1_UNDEF_CV(varname, BP_VAR_R);
|
||||
}
|
||||
name = zval_get_string(varname);
|
||||
name = zval_get_tmp_string(varname, &tmp_name);
|
||||
}
|
||||
|
||||
target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK EXECUTE_DATA_CC);
|
||||
@ -1435,7 +1435,7 @@ ZEND_VM_C_LABEL(fetch_this):
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
}
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_string_release(name);
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
|
||||
}
|
||||
@ -1487,7 +1487,7 @@ ZEND_VM_C_LABEL(fetch_this):
|
||||
}
|
||||
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_string_release(name);
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
|
||||
ZEND_ASSERT(retval != NULL);
|
||||
@ -5418,7 +5418,8 @@ ZEND_VM_HANDLER(196, ZEND_UNSET_CV, CV, UNUSED)
|
||||
ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH)
|
||||
{
|
||||
USE_OPLINE
|
||||
zval tmp, *varname;
|
||||
zval *varname;
|
||||
zend_string *name, *tmp_name;
|
||||
HashTable *target_symbol_table;
|
||||
zend_free_op free_op1;
|
||||
|
||||
@ -5426,20 +5427,23 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH)
|
||||
|
||||
varname = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
|
||||
|
||||
ZVAL_UNDEF(&tmp);
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
|
||||
if (OP1_TYPE == IS_CONST) {
|
||||
name = Z_STR_P(varname);
|
||||
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
|
||||
name = Z_STR_P(varname);
|
||||
tmp_name = NULL;
|
||||
} else {
|
||||
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
|
||||
varname = GET_OP1_UNDEF_CV(varname, BP_VAR_R);
|
||||
}
|
||||
ZVAL_STR(&tmp, zval_get_string(varname));
|
||||
varname = &tmp;
|
||||
name = zval_get_tmp_string(varname, &tmp_name);
|
||||
}
|
||||
|
||||
target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK EXECUTE_DATA_CC);
|
||||
zend_hash_del_ind(target_symbol_table, Z_STR_P(varname));
|
||||
zend_hash_del_ind(target_symbol_table, name);
|
||||
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
|
||||
zend_string_release(Z_STR(tmp));
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
FREE_OP1();
|
||||
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
|
||||
@ -5448,7 +5452,8 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH)
|
||||
ZEND_VM_HANDLER(179, ZEND_UNSET_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH|CONST|VAR)
|
||||
{
|
||||
USE_OPLINE
|
||||
zval tmp, *varname;
|
||||
zval *varname;
|
||||
zend_string *name, *tmp_name;
|
||||
zend_class_entry *ce;
|
||||
zend_free_op free_op1;
|
||||
|
||||
@ -5456,13 +5461,16 @@ ZEND_VM_HANDLER(179, ZEND_UNSET_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH
|
||||
|
||||
varname = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R);
|
||||
|
||||
ZVAL_UNDEF(&tmp);
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
|
||||
if (OP1_TYPE == IS_CONST) {
|
||||
name = Z_STR_P(varname);
|
||||
} else if (EXPECTED(Z_TYPE_P(varname) == IS_STRING)) {
|
||||
name = Z_STR_P(varname);
|
||||
tmp_name = NULL;
|
||||
} else {
|
||||
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(varname) == IS_UNDEF)) {
|
||||
varname = GET_OP1_UNDEF_CV(varname, BP_VAR_R);
|
||||
}
|
||||
ZVAL_STR(&tmp, zval_get_string(varname));
|
||||
varname = &tmp;
|
||||
name = zval_get_tmp_string(varname, &tmp_name);
|
||||
}
|
||||
|
||||
if (OP2_TYPE == IS_CONST) {
|
||||
@ -5471,8 +5479,8 @@ ZEND_VM_HANDLER(179, ZEND_UNSET_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH
|
||||
ce = zend_fetch_class_by_name(Z_STR_P(RT_CONSTANT(opline, opline->op2)), RT_CONSTANT(opline, opline->op2) + 1, ZEND_FETCH_CLASS_DEFAULT | ZEND_FETCH_CLASS_EXCEPTION);
|
||||
if (UNEXPECTED(ce == NULL)) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
|
||||
zend_string_release(Z_STR(tmp));
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
FREE_OP1();
|
||||
HANDLE_EXCEPTION();
|
||||
@ -5483,8 +5491,8 @@ ZEND_VM_HANDLER(179, ZEND_UNSET_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH
|
||||
ce = zend_fetch_class(NULL, opline->op2.num);
|
||||
if (UNEXPECTED(ce == NULL)) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
|
||||
zend_string_release(Z_STR(tmp));
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
FREE_OP1();
|
||||
HANDLE_EXCEPTION();
|
||||
@ -5492,10 +5500,10 @@ ZEND_VM_HANDLER(179, ZEND_UNSET_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLASS_FETCH
|
||||
} else {
|
||||
ce = Z_CE_P(EX_VAR(opline->op2.var));
|
||||
}
|
||||
zend_std_unset_static_property(ce, Z_STR_P(varname));
|
||||
zend_std_unset_static_property(ce, name);
|
||||
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
|
||||
zend_string_release(Z_STR(tmp));
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
FREE_OP1();
|
||||
ZEND_VM_NEXT_OPCODE_CHECK_EXCEPTION();
|
||||
@ -6234,22 +6242,23 @@ ZEND_VM_HANDLER(114, ZEND_ISSET_ISEMPTY_VAR, CONST|TMPVAR|CV, UNUSED, VAR_FETCH|
|
||||
zval *value;
|
||||
int result;
|
||||
zend_free_op free_op1;
|
||||
zval tmp, *varname;
|
||||
zval *varname;
|
||||
zend_string *name, *tmp_name;
|
||||
HashTable *target_symbol_table;
|
||||
|
||||
SAVE_OPLINE();
|
||||
varname = GET_OP1_ZVAL_PTR(BP_VAR_IS);
|
||||
ZVAL_UNDEF(&tmp);
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
|
||||
ZVAL_STR(&tmp, zval_get_string(varname));
|
||||
varname = &tmp;
|
||||
if (OP1_TYPE == IS_CONST) {
|
||||
name = Z_STR_P(varname);
|
||||
} else {
|
||||
name = zval_get_tmp_string(varname, &tmp_name);
|
||||
}
|
||||
|
||||
target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK EXECUTE_DATA_CC);
|
||||
value = zend_hash_find_ind(target_symbol_table, Z_STR_P(varname));
|
||||
value = zend_hash_find_ind(target_symbol_table, name);
|
||||
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
|
||||
zend_string_release(Z_STR(tmp));
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
FREE_OP1();
|
||||
|
||||
@ -6271,15 +6280,16 @@ ZEND_VM_HANDLER(180, ZEND_ISSET_ISEMPTY_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLA
|
||||
zval *value;
|
||||
int result;
|
||||
zend_free_op free_op1;
|
||||
zval tmp, *varname;
|
||||
zval *varname;
|
||||
zend_string *name, *tmp_name;
|
||||
zend_class_entry *ce;
|
||||
|
||||
SAVE_OPLINE();
|
||||
varname = GET_OP1_ZVAL_PTR(BP_VAR_IS);
|
||||
ZVAL_UNDEF(&tmp);
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE_P(varname) != IS_STRING) {
|
||||
ZVAL_STR(&tmp, zval_get_string(varname));
|
||||
varname = &tmp;
|
||||
if (OP1_TYPE == IS_CONST) {
|
||||
name = Z_STR_P(varname);
|
||||
} else {
|
||||
name = zval_get_tmp_string(varname, &tmp_name);
|
||||
}
|
||||
|
||||
if (OP2_TYPE == IS_CONST) {
|
||||
@ -6306,8 +6316,8 @@ ZEND_VM_HANDLER(180, ZEND_ISSET_ISEMPTY_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLA
|
||||
ce = zend_fetch_class(NULL, opline->op2.num);
|
||||
if (UNEXPECTED(ce == NULL)) {
|
||||
ZEND_ASSERT(EG(exception));
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
|
||||
zend_string_release(Z_STR(tmp));
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
FREE_OP1();
|
||||
ZVAL_UNDEF(EX_VAR(opline->result.var));
|
||||
@ -6330,14 +6340,14 @@ ZEND_VM_HANDLER(180, ZEND_ISSET_ISEMPTY_STATIC_PROP, CONST|TMPVAR|CV, UNUSED|CLA
|
||||
}
|
||||
}
|
||||
|
||||
value = zend_std_get_static_property(ce, Z_STR_P(varname), 1);
|
||||
value = zend_std_get_static_property(ce, name, 1);
|
||||
|
||||
if (OP1_TYPE == IS_CONST && value) {
|
||||
CACHE_POLYMORPHIC_PTR(Z_CACHE_SLOT_P(RT_CONSTANT(opline, opline->op1)), ce, value);
|
||||
}
|
||||
|
||||
if (OP1_TYPE != IS_CONST && Z_TYPE(tmp) != IS_UNDEF) {
|
||||
zend_string_release(Z_STR(tmp));
|
||||
if (OP1_TYPE != IS_CONST) {
|
||||
zend_tmp_string_release(tmp_name);
|
||||
}
|
||||
FREE_OP1();
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -2393,9 +2393,10 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
case CURLOPT_DEFAULT_PROTOCOL:
|
||||
#endif
|
||||
{
|
||||
zend_string *str = zval_get_string(zvalue);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
||||
int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2427,9 +2428,10 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
if (Z_ISNULL_P(zvalue)) {
|
||||
error = curl_easy_setopt(ch->cp, option, NULL);
|
||||
} else {
|
||||
zend_string *str = zval_get_string(zvalue);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
||||
int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
@ -2438,18 +2440,20 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
/* Curl private option */
|
||||
case CURLOPT_PRIVATE:
|
||||
{
|
||||
zend_string *str = zval_get_string(zvalue);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
||||
int ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 1);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Curl url option */
|
||||
case CURLOPT_URL:
|
||||
{
|
||||
zend_string *str = zval_get_string(zvalue);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
||||
int ret = php_curl_option_url(ch, ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2572,7 +2576,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
{
|
||||
zval *current;
|
||||
HashTable *ph;
|
||||
zend_string *val;
|
||||
zend_string *val, *tmp_val;
|
||||
struct curl_slist *slist = NULL;
|
||||
|
||||
ph = HASH_OF(zvalue);
|
||||
@ -2624,9 +2628,9 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
|
||||
ZEND_HASH_FOREACH_VAL(ph, current) {
|
||||
ZVAL_DEREF(current);
|
||||
val = zval_get_string(current);
|
||||
val = zval_get_tmp_string(current, &tmp_val);
|
||||
slist = curl_slist_append(slist, ZSTR_VAL(val));
|
||||
zend_string_release(val);
|
||||
zend_tmp_string_release(tmp_val);
|
||||
if (!slist) {
|
||||
php_error_docref(NULL, E_WARNING, "Could not build curl_slist");
|
||||
return 1;
|
||||
@ -2687,7 +2691,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
}
|
||||
|
||||
ZEND_HASH_FOREACH_KEY_VAL(postfields, num_key, string_key, current) {
|
||||
zend_string *postval;
|
||||
zend_string *postval, *tmp_postval;
|
||||
/* Pretend we have a string_key here */
|
||||
if (!string_key) {
|
||||
string_key = zend_long_to_str(num_key);
|
||||
@ -2737,7 +2741,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
continue;
|
||||
}
|
||||
|
||||
postval = zval_get_string(current);
|
||||
postval = zval_get_tmp_string(current, &tmp_postval);
|
||||
|
||||
/* The arguments after _NAMELENGTH and _CONTENTSLENGTH
|
||||
* must be explicitly cast to long in curl_formadd
|
||||
@ -2753,7 +2757,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
/* Not nice to convert between enums but we only have place for one error type */
|
||||
error = (CURLcode)form_error;
|
||||
}
|
||||
zend_string_release(postval);
|
||||
zend_tmp_string_release(tmp_postval);
|
||||
zend_string_release(string_key);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
@ -2769,21 +2773,23 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
error = curl_easy_setopt(ch->cp, CURLOPT_HTTPPOST, first);
|
||||
} else {
|
||||
#if LIBCURL_VERSION_NUM >= 0x071101
|
||||
zend_string *str = zval_get_string(zvalue);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
||||
/* with curl 7.17.0 and later, we can use COPYPOSTFIELDS, but we have to provide size before */
|
||||
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str));
|
||||
error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, ZSTR_VAL(str));
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
#else
|
||||
char *post = NULL;
|
||||
zend_string *str = zval_get_string(zvalue);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
||||
|
||||
post = estrndup(ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
zend_llist_add_element(&ch->to_free->str, &post);
|
||||
|
||||
curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, post);
|
||||
error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str));
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@ -2873,16 +2879,17 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
|
||||
case CURLOPT_SSH_KNOWNHOSTS:
|
||||
#endif
|
||||
{
|
||||
zend_string *str = zval_get_string(zvalue);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(zvalue, &tmp_str);
|
||||
int ret;
|
||||
|
||||
if (ZSTR_LEN(str) && php_check_open_basedir(ZSTR_VAL(str))) {
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
ret = php_curl_option_str(ch, option, ZSTR_VAL(str), ZSTR_LEN(str), 0);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -4353,9 +4353,10 @@ static int php_date_interval_initialize_from_hash(zval **return_value, php_inter
|
||||
do { \
|
||||
zval *z_arg = zend_hash_str_find(myht, element, sizeof(element) - 1); \
|
||||
if (z_arg && Z_TYPE_P(z_arg) <= IS_STRING) { \
|
||||
zend_string *str = zval_get_string(z_arg); \
|
||||
zend_string *tmp_str; \
|
||||
zend_string *str = zval_get_tmp_string(z_arg, &tmp_str); \
|
||||
DATE_A64I((*intobj)->diff->member, ZSTR_VAL(str)); \
|
||||
zend_string_release(str); \
|
||||
zend_tmp_string_release(tmp_str); \
|
||||
} else { \
|
||||
(*intobj)->diff->member = -1LL; \
|
||||
} \
|
||||
|
@ -1415,8 +1415,12 @@ static zend_string *preg_do_repl_func(zend_fcall_info *fci, zend_fcall_info_cach
|
||||
fci->no_separation = 0;
|
||||
|
||||
if (zend_call_function(fci, fcc) == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
|
||||
result_str = zval_get_string(&retval);
|
||||
if (EXPECTED(Z_TYPE(retval) == IS_STRING)) {
|
||||
result_str = Z_STR(retval);
|
||||
} else {
|
||||
result_str = zval_get_string_func(&retval);
|
||||
zval_ptr_dtor(&retval);
|
||||
}
|
||||
} else {
|
||||
if (!EG(exception)) {
|
||||
php_error_docref(NULL, E_WARNING, "Unable to call custom replacement function");
|
||||
@ -1933,7 +1937,7 @@ static zend_string *php_pcre_replace_array(HashTable *regex, zval *replace, zend
|
||||
{
|
||||
zval *regex_entry;
|
||||
zend_string *result;
|
||||
zend_string *replace_str;
|
||||
zend_string *replace_str, *tmp_replace_str;
|
||||
|
||||
if (Z_TYPE_P(replace) == IS_ARRAY) {
|
||||
uint32_t replace_idx = 0;
|
||||
@ -1942,19 +1946,21 @@ static zend_string *php_pcre_replace_array(HashTable *regex, zval *replace, zend
|
||||
/* For each entry in the regex array, get the entry */
|
||||
ZEND_HASH_FOREACH_VAL(regex, regex_entry) {
|
||||
/* Make sure we're dealing with strings. */
|
||||
zend_string *regex_str = zval_get_string(regex_entry);
|
||||
zend_string *tmp_regex_str;
|
||||
zend_string *regex_str = zval_get_tmp_string(regex_entry, &tmp_regex_str);
|
||||
zval *zv;
|
||||
|
||||
/* Get current entry */
|
||||
while (1) {
|
||||
if (replace_idx == replace_ht->nNumUsed) {
|
||||
replace_str = ZSTR_EMPTY_ALLOC();
|
||||
tmp_replace_str = NULL;
|
||||
break;
|
||||
}
|
||||
zv = &replace_ht->arData[replace_idx].val;
|
||||
replace_idx++;
|
||||
if (Z_TYPE_P(zv) != IS_UNDEF) {
|
||||
replace_str = zval_get_string(zv);
|
||||
replace_str = zval_get_tmp_string(zv, &tmp_replace_str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1968,8 +1974,8 @@ static zend_string *php_pcre_replace_array(HashTable *regex, zval *replace, zend
|
||||
replace_str,
|
||||
limit,
|
||||
replace_count);
|
||||
zend_string_release(replace_str);
|
||||
zend_string_release(regex_str);
|
||||
zend_tmp_string_release(tmp_replace_str);
|
||||
zend_tmp_string_release(tmp_regex_str);
|
||||
zend_string_release(subject_str);
|
||||
subject_str = result;
|
||||
if (UNEXPECTED(result == NULL)) {
|
||||
@ -1983,7 +1989,8 @@ static zend_string *php_pcre_replace_array(HashTable *regex, zval *replace, zend
|
||||
/* For each entry in the regex array, get the entry */
|
||||
ZEND_HASH_FOREACH_VAL(regex, regex_entry) {
|
||||
/* Make sure we're dealing with strings. */
|
||||
zend_string *regex_str = zval_get_string(regex_entry);
|
||||
zend_string *tmp_regex_str;
|
||||
zend_string *regex_str = zval_get_tmp_string(regex_entry, &tmp_regex_str);
|
||||
|
||||
/* Do the actual replacement and put the result back into subject_str
|
||||
for further replacements. */
|
||||
@ -1994,7 +2001,7 @@ static zend_string *php_pcre_replace_array(HashTable *regex, zval *replace, zend
|
||||
replace_str,
|
||||
limit,
|
||||
replace_count);
|
||||
zend_string_release(regex_str);
|
||||
zend_tmp_string_release(tmp_regex_str);
|
||||
zend_string_release(subject_str);
|
||||
subject_str = result;
|
||||
|
||||
@ -2057,7 +2064,8 @@ static zend_string *php_replace_in_subject_func(zval *regex, zend_fcall_info *fc
|
||||
/* For each entry in the regex array, get the entry */
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(regex), regex_entry) {
|
||||
/* Make sure we're dealing with strings. */
|
||||
zend_string *regex_str = zval_get_string(regex_entry);
|
||||
zend_string *tmp_regex_str;
|
||||
zend_string *regex_str = zval_get_tmp_string(regex_entry, &tmp_regex_str);
|
||||
|
||||
/* Do the actual replacement and put the result back into subject_str
|
||||
for further replacements. */
|
||||
@ -2066,7 +2074,7 @@ static zend_string *php_replace_in_subject_func(zval *regex, zend_fcall_info *fc
|
||||
fci, fcc,
|
||||
limit,
|
||||
replace_count);
|
||||
zend_string_release(regex_str);
|
||||
zend_tmp_string_release(tmp_regex_str);
|
||||
zend_string_release(subject_str);
|
||||
subject_str = result;
|
||||
if (UNEXPECTED(result == NULL)) {
|
||||
|
@ -547,10 +547,11 @@ static void _const_string(smart_str *str, char *name, zval *value, char *indent)
|
||||
smart_str_append_printf(str, "%s Constant [ %s %s ] { %s }\n",
|
||||
indent, type, name, Z_STRVAL_P(value));
|
||||
} else {
|
||||
zend_string *value_str = zval_get_string(value);
|
||||
zend_string *tmp_value_str;
|
||||
zend_string *value_str = zval_get_tmp_string(value, &tmp_value_str);
|
||||
smart_str_append_printf(str, "%s Constant [ %s %s ] { %s }\n",
|
||||
indent, type, name, ZSTR_VAL(value_str));
|
||||
zend_string_release(value_str);
|
||||
zend_tmp_string_release(tmp_value_str);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -568,12 +569,13 @@ static void _class_const_string(smart_str *str, char *name, zend_class_constant
|
||||
smart_str_append_printf(str, "%sConstant [ %s %s %s ] { Array }\n",
|
||||
indent, visibility, type, name);
|
||||
} else {
|
||||
zend_string *value_str = zval_get_string(&c->value);
|
||||
zend_string *tmp_value_str;
|
||||
zend_string *value_str = zval_get_tmp_string(&c->value, &tmp_value_str);
|
||||
|
||||
smart_str_append_printf(str, "%sConstant [ %s %s %s ] { %s }\n",
|
||||
indent, visibility, type, name, ZSTR_VAL(value_str));
|
||||
|
||||
zend_string_release(value_str);
|
||||
zend_tmp_string_release(tmp_value_str);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -660,9 +662,10 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_
|
||||
} else if (Z_TYPE(zv) == IS_ARRAY) {
|
||||
smart_str_appends(str, "Array");
|
||||
} else {
|
||||
zend_string *zv_str = zval_get_string(&zv);
|
||||
zend_string *tmp_zv_str;
|
||||
zend_string *zv_str = zval_get_tmp_string(&zv, &tmp_zv_str);
|
||||
smart_str_append(str, zv_str);
|
||||
zend_string_release(zv_str);
|
||||
zend_tmp_string_release(tmp_zv_str);
|
||||
}
|
||||
zval_ptr_dtor(&zv);
|
||||
}
|
||||
|
@ -2383,11 +2383,12 @@ static PHP_FUNCTION(session_start)
|
||||
if (zend_string_equals_literal(str_idx, "read_and_close")) {
|
||||
read_and_close = zval_get_long(value);
|
||||
} else {
|
||||
zend_string *val = zval_get_string(value);
|
||||
zend_string *tmp_val;
|
||||
zend_string *val = zval_get_tmp_string(value, &tmp_val);
|
||||
if (php_session_start_set_ini(str_idx, val) == FAILURE) {
|
||||
php_error_docref(NULL, E_WARNING, "Setting option '%s' failed", ZSTR_VAL(str_idx));
|
||||
}
|
||||
zend_string_release(val);
|
||||
zend_tmp_string_release(tmp_val);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -260,7 +260,7 @@ long_dim:
|
||||
name = NULL;
|
||||
} else {
|
||||
if (Z_TYPE_P(member) != IS_STRING) {
|
||||
ZVAL_STR(&tmp_zv, zval_get_string(member));
|
||||
ZVAL_STR(&tmp_zv, zval_get_string_func(member));
|
||||
member = &tmp_zv;
|
||||
}
|
||||
name = Z_STRVAL_P(member);
|
||||
@ -468,7 +468,7 @@ long_dim:
|
||||
}
|
||||
} else {
|
||||
if (Z_TYPE_P(member) != IS_STRING) {
|
||||
trim_str = zval_get_string(member);
|
||||
trim_str = zval_get_string_func(member);
|
||||
ZVAL_STR(&tmp_zv, php_trim(trim_str, NULL, 0, 3));
|
||||
zend_string_release(trim_str);
|
||||
member = &tmp_zv;
|
||||
@ -726,7 +726,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend
|
||||
zval tmp_zv;
|
||||
|
||||
if (Z_TYPE_P(member) != IS_STRING && Z_TYPE_P(member) != IS_LONG) {
|
||||
ZVAL_STR(&tmp_zv, zval_get_string(member));
|
||||
ZVAL_STR(&tmp_zv, zval_get_string_func(member));
|
||||
member = &tmp_zv;
|
||||
}
|
||||
|
||||
@ -845,7 +845,7 @@ static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements,
|
||||
int test = 0;
|
||||
|
||||
if (Z_TYPE_P(member) != IS_STRING && Z_TYPE_P(member) != IS_LONG) {
|
||||
ZVAL_STR(&tmp_zv, zval_get_string(member));
|
||||
ZVAL_STR(&tmp_zv, zval_get_string_func(member));
|
||||
member = &tmp_zv;
|
||||
}
|
||||
|
||||
|
@ -845,7 +845,7 @@ static xmlNodePtr to_xml_string(encodeTypePtr type, zval *data, int style, xmlNo
|
||||
str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
|
||||
new_len = Z_STRLEN_P(data);
|
||||
} else {
|
||||
zend_string *tmp = zval_get_string(data);
|
||||
zend_string *tmp = zval_get_string_func(data);
|
||||
str = estrndup(ZSTR_VAL(tmp), ZSTR_LEN(tmp));
|
||||
new_len = ZSTR_LEN(tmp);
|
||||
zend_string_release(tmp);
|
||||
@ -928,7 +928,7 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo
|
||||
if (Z_TYPE_P(data) == IS_STRING) {
|
||||
str = php_base64_encode((unsigned char*)Z_STRVAL_P(data), Z_STRLEN_P(data));
|
||||
} else {
|
||||
zend_string *tmp = zval_get_string(data);
|
||||
zend_string *tmp = zval_get_string_func(data);
|
||||
str = php_base64_encode((unsigned char*) ZSTR_VAL(tmp), ZSTR_LEN(tmp));
|
||||
zend_string_release(tmp);
|
||||
}
|
||||
@ -956,7 +956,7 @@ static xmlNodePtr to_xml_hexbin(encodeTypePtr type, zval *data, int style, xmlNo
|
||||
FIND_ZVAL_NULL(data, ret, style);
|
||||
|
||||
if (Z_TYPE_P(data) != IS_STRING) {
|
||||
ZVAL_STR(&tmp, zval_get_string(data));
|
||||
ZVAL_STR(&tmp, zval_get_string_func(data));
|
||||
data = &tmp;
|
||||
}
|
||||
str = (unsigned char *) safe_emalloc(Z_STRLEN_P(data) * 2, sizeof(char), 1);
|
||||
@ -3029,7 +3029,7 @@ static xmlNodePtr to_xml_list(encodeTypePtr enc, zval *data, int style, xmlNodeP
|
||||
smart_str list = {0};
|
||||
|
||||
if (Z_TYPE_P(data) != IS_STRING) {
|
||||
ZVAL_STR(&tmp, zval_get_string(data));
|
||||
ZVAL_STR(&tmp, zval_get_string_func(data));
|
||||
data = &tmp;
|
||||
}
|
||||
str = estrndup(Z_STRVAL_P(data), Z_STRLEN_P(data));
|
||||
@ -3139,7 +3139,7 @@ static xmlNodePtr to_xml_any(encodeTypePtr type, zval *data, int style, xmlNodeP
|
||||
if (Z_TYPE_P(data) == IS_STRING) {
|
||||
ret = xmlNewTextLen(BAD_CAST(Z_STRVAL_P(data)), Z_STRLEN_P(data));
|
||||
} else {
|
||||
zend_string *tmp = zval_get_string(data);
|
||||
zend_string *tmp = zval_get_string_func(data);
|
||||
ret = xmlNewTextLen(BAD_CAST(ZSTR_VAL(tmp)), ZSTR_LEN(tmp));
|
||||
zend_string_release(tmp);
|
||||
}
|
||||
|
@ -541,9 +541,9 @@ static void from_zval_write_sin_addr(const zval *zaddr_str, char *inaddr, ser_co
|
||||
{
|
||||
int res;
|
||||
struct sockaddr_in saddr = {0};
|
||||
zend_string *addr_str;
|
||||
zend_string *addr_str, *tmp_addr_str;
|
||||
|
||||
addr_str = zval_get_string((zval *) zaddr_str);
|
||||
addr_str = zval_get_tmp_string((zval *) zaddr_str, &tmp_addr_str);
|
||||
res = php_set_inet_addr(&saddr, ZSTR_VAL(addr_str), ctx->sock);
|
||||
if (res) {
|
||||
memcpy(inaddr, &saddr.sin_addr, sizeof saddr.sin_addr);
|
||||
@ -553,7 +553,7 @@ static void from_zval_write_sin_addr(const zval *zaddr_str, char *inaddr, ser_co
|
||||
"address", ZSTR_VAL(addr_str));
|
||||
}
|
||||
|
||||
zend_string_release(addr_str);
|
||||
zend_tmp_string_release(tmp_addr_str);
|
||||
}
|
||||
static void to_zval_read_sin_addr(const char *data, zval *zv, res_context *ctx)
|
||||
{
|
||||
@ -591,9 +591,9 @@ static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_co
|
||||
{
|
||||
int res;
|
||||
struct sockaddr_in6 saddr6 = {0};
|
||||
zend_string *addr_str;
|
||||
zend_string *addr_str, *tmp_addr_str;
|
||||
|
||||
addr_str = zval_get_string((zval *) zaddr_str);
|
||||
addr_str = zval_get_tmp_string((zval *) zaddr_str, &tmp_addr_str);
|
||||
res = php_set_inet6_addr(&saddr6, ZSTR_VAL(addr_str), ctx->sock);
|
||||
if (res) {
|
||||
memcpy(addr6, &saddr6.sin6_addr, sizeof saddr6.sin6_addr);
|
||||
@ -603,7 +603,7 @@ static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_co
|
||||
"address", Z_STRVAL_P(zaddr_str));
|
||||
}
|
||||
|
||||
zend_string_release(addr_str);
|
||||
zend_tmp_string_release(tmp_addr_str);
|
||||
}
|
||||
static void to_zval_read_sin6_addr(const char *data, zval *zv, res_context *ctx)
|
||||
{
|
||||
@ -642,28 +642,30 @@ static void to_zval_read_sockaddr_in6(const char *data, zval *zv, res_context *c
|
||||
#endif /* HAVE_IPV6 */
|
||||
static void from_zval_write_sun_path(const zval *path, char *sockaddr_un_c, ser_context *ctx)
|
||||
{
|
||||
zend_string *path_str;
|
||||
zend_string *path_str, *tmp_path_str;
|
||||
struct sockaddr_un *saddr = (struct sockaddr_un*)sockaddr_un_c;
|
||||
|
||||
path_str = zval_get_string((zval *) path);
|
||||
path_str = zval_get_tmp_string((zval *) path, &tmp_path_str);
|
||||
|
||||
/* code in this file relies on the path being nul terminated, even though
|
||||
* this is not required, at least on linux for abstract paths. It also
|
||||
* assumes that the path is not empty */
|
||||
if (ZSTR_LEN(path_str) == 0) {
|
||||
do_from_zval_err(ctx, "%s", "the path is cannot be empty");
|
||||
zend_tmp_string_release(tmp_path_str);
|
||||
return;
|
||||
}
|
||||
if (ZSTR_LEN(path_str) >= sizeof(saddr->sun_path)) {
|
||||
do_from_zval_err(ctx, "the path is too long, the maximum permitted "
|
||||
"length is %zd", sizeof(saddr->sun_path) - 1);
|
||||
zend_tmp_string_release(tmp_path_str);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(&saddr->sun_path, ZSTR_VAL(path_str), ZSTR_LEN(path_str));
|
||||
saddr->sun_path[ZSTR_LEN(path_str)] = '\0';
|
||||
|
||||
zend_string_release(path_str);
|
||||
zend_tmp_string_release(tmp_path_str);
|
||||
}
|
||||
static void to_zval_read_sun_path(const char *data, zval *zv, res_context *ctx) {
|
||||
struct sockaddr_un *saddr = (struct sockaddr_un*)data;
|
||||
@ -1076,15 +1078,15 @@ static void from_zval_write_iov_array_aux(zval *elem, unsigned i, void **args, s
|
||||
{
|
||||
struct msghdr *msg = args[0];
|
||||
size_t len;
|
||||
zend_string *str;
|
||||
zend_string *str, *tmp_str;
|
||||
|
||||
str = zval_get_string(elem);
|
||||
str = zval_get_tmp_string(elem, &tmp_str);
|
||||
|
||||
msg->msg_iov[i - 1].iov_base = accounted_emalloc(ZSTR_LEN(str), ctx);
|
||||
msg->msg_iov[i - 1].iov_len = ZSTR_LEN(str);
|
||||
memcpy(msg->msg_iov[i - 1].iov_base, ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
}
|
||||
static void from_zval_write_iov_array(const zval *arr, char *msghdr_c, ser_context *ctx)
|
||||
{
|
||||
@ -1240,9 +1242,9 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context
|
||||
ret = (unsigned)Z_LVAL_P(zv);
|
||||
}
|
||||
} else {
|
||||
zend_string *str;
|
||||
zend_string *str, *tmp_str;
|
||||
|
||||
str = zval_get_string((zval *) zv);
|
||||
str = zval_get_tmp_string((zval *) zv, &tmp_str);
|
||||
|
||||
#if HAVE_IF_NAMETOINDEX
|
||||
ret = if_nametoindex(ZSTR_VAL(str));
|
||||
@ -1274,7 +1276,7 @@ static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context
|
||||
"name, an integer interface index must be supplied instead");
|
||||
#endif
|
||||
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
}
|
||||
|
||||
if (!ctx->err.has_error) {
|
||||
|
@ -100,9 +100,10 @@ static int php_get_if_index_from_zval(zval *val, unsigned *out)
|
||||
ret = SUCCESS;
|
||||
}
|
||||
} else {
|
||||
zend_string *str = zval_get_string(val);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(val, &tmp_str);
|
||||
ret = php_string_to_if_index(ZSTR_VAL(str), out);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -127,18 +128,18 @@ static int php_get_address_from_array(const HashTable *ht, const char *key,
|
||||
php_socket *sock, php_sockaddr_storage *ss, socklen_t *ss_len)
|
||||
{
|
||||
zval *val;
|
||||
zend_string *str;
|
||||
zend_string *str, *tmp_str;
|
||||
|
||||
if ((val = zend_hash_str_find(ht, key, strlen(key))) == NULL) {
|
||||
php_error_docref(NULL, E_WARNING, "no key \"%s\" passed in optval", key);
|
||||
return FAILURE;
|
||||
}
|
||||
str = zval_get_string(val);
|
||||
str = zval_get_tmp_string(val, &tmp_str);
|
||||
if (!php_set_inet46_addr(ss, ss_len, ZSTR_VAL(str), sock)) {
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return FAILURE;
|
||||
}
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -498,13 +498,14 @@ static int php_array_natural_general_compare(const void *a, const void *b, int f
|
||||
{
|
||||
Bucket *f = (Bucket *) a;
|
||||
Bucket *s = (Bucket *) b;
|
||||
zend_string *str1 = zval_get_string(&f->val);
|
||||
zend_string *str2 = zval_get_string(&s->val);
|
||||
zend_string *tmp_str1, *tmp_str2;
|
||||
zend_string *str1 = zval_get_tmp_string(&f->val, &tmp_str1);
|
||||
zend_string *str2 = zval_get_tmp_string(&s->val, &tmp_str2);
|
||||
|
||||
int result = strnatcmp_ex(ZSTR_VAL(str1), ZSTR_LEN(str1), ZSTR_VAL(str2), ZSTR_LEN(str2), fold_case);
|
||||
|
||||
zend_string_release(str1);
|
||||
zend_string_release(str2);
|
||||
zend_tmp_string_release(tmp_str1);
|
||||
zend_tmp_string_release(tmp_str2);
|
||||
return result;
|
||||
}
|
||||
/* }}} */
|
||||
@ -2713,9 +2714,10 @@ PHP_FUNCTION(array_fill_keys)
|
||||
if (Z_TYPE_P(entry) == IS_LONG) {
|
||||
zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL_P(entry), val);
|
||||
} else {
|
||||
zend_string *key = zval_get_string(entry);
|
||||
zend_string *tmp_key;
|
||||
zend_string *key = zval_get_tmp_string(entry, &tmp_key);
|
||||
zend_symtable_update(Z_ARRVAL_P(return_value), key, val);
|
||||
zend_string_release(key);
|
||||
zend_tmp_string_release(tmp_key);
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
@ -4203,9 +4205,10 @@ PHP_FUNCTION(array_column)
|
||||
} else if (Z_TYPE_P(zkeyval) == IS_LONG) {
|
||||
add_index_zval(return_value, Z_LVAL_P(zkeyval), zcolval);
|
||||
} else if (Z_TYPE_P(zkeyval) == IS_OBJECT) {
|
||||
zend_string *key = zval_get_string(zkeyval);
|
||||
zend_string *tmp_key;
|
||||
zend_string *key = zval_get_tmp_string(zkeyval, &tmp_key);
|
||||
zend_symtable_update(Z_ARRVAL_P(return_value), key, zcolval);
|
||||
zend_string_release(key);
|
||||
zend_tmp_string_release(tmp_key);
|
||||
} else {
|
||||
add_next_index_zval(return_value, zcolval);
|
||||
}
|
||||
@ -4483,9 +4486,10 @@ PHP_FUNCTION(array_unique)
|
||||
if (Z_TYPE_P(val) == IS_STRING) {
|
||||
retval = zend_hash_add_empty_element(&seen, Z_STR_P(val));
|
||||
} else {
|
||||
zend_string *str_val = zval_get_string(val);
|
||||
zend_string *tmp_str_val;
|
||||
zend_string *str_val = zval_get_tmp_string(val, &tmp_str_val);
|
||||
retval = zend_hash_add_empty_element(&seen, str_val);
|
||||
zend_string_release(str_val);
|
||||
zend_tmp_string_release(tmp_str_val);
|
||||
}
|
||||
|
||||
if (retval) {
|
||||
@ -5367,7 +5371,7 @@ PHP_FUNCTION(array_diff)
|
||||
uint32_t num;
|
||||
HashTable exclude;
|
||||
zval *value;
|
||||
zend_string *str, *key;
|
||||
zend_string *str, *tmp_str, *key;
|
||||
zend_long idx;
|
||||
zval dummy;
|
||||
|
||||
@ -5405,16 +5409,16 @@ PHP_FUNCTION(array_diff)
|
||||
zend_hash_init(&exclude, num, NULL, NULL, 0);
|
||||
for (i = 1; i < argc; i++) {
|
||||
ZEND_HASH_FOREACH_VAL_IND(Z_ARRVAL(args[i]), value) {
|
||||
str = zval_get_string(value);
|
||||
str = zval_get_tmp_string(value, &tmp_str);
|
||||
zend_hash_add(&exclude, str, &dummy);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
|
||||
/* copy all elements of first array that are not in exclude set */
|
||||
array_init_size(return_value, zend_hash_num_elements(Z_ARRVAL(args[0])));
|
||||
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL(args[0]), idx, key, value) {
|
||||
str = zval_get_string(value);
|
||||
str = zval_get_tmp_string(value, &tmp_str);
|
||||
if (!zend_hash_exists(&exclude, str)) {
|
||||
if (key) {
|
||||
value = zend_hash_add_new(Z_ARRVAL_P(return_value), key, value);
|
||||
@ -5423,7 +5427,7 @@ PHP_FUNCTION(array_diff)
|
||||
}
|
||||
zval_add_ref(value);
|
||||
}
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
zend_hash_destroy(&exclude);
|
||||
@ -6316,10 +6320,11 @@ PHP_FUNCTION(array_combine)
|
||||
entry_values = zend_hash_index_update(Z_ARRVAL_P(return_value),
|
||||
Z_LVAL_P(entry_keys), entry_values);
|
||||
} else {
|
||||
zend_string *key = zval_get_string(entry_keys);
|
||||
zend_string *tmp_key;
|
||||
zend_string *key = zval_get_tmp_string(entry_keys, &tmp_key);
|
||||
entry_values = zend_symtable_update(Z_ARRVAL_P(return_value),
|
||||
key, entry_values);
|
||||
zend_string_release(key);
|
||||
zend_tmp_string_release(tmp_key);
|
||||
}
|
||||
zval_add_ref(entry_values);
|
||||
pos_values++;
|
||||
|
@ -4336,11 +4336,12 @@ PHP_FUNCTION(getopt)
|
||||
|
||||
/* Iterate over the hash to construct the argv array. */
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(args), entry) {
|
||||
zend_string *arg_str = zval_get_string(entry);
|
||||
zend_string *tmp_arg_str;
|
||||
zend_string *arg_str = zval_get_tmp_string(entry, &tmp_arg_str);
|
||||
|
||||
argv[pos++] = estrdup(ZSTR_VAL(arg_str));
|
||||
|
||||
zend_string_release(arg_str);
|
||||
zend_tmp_string_release(tmp_arg_str);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
/* The C Standard requires argv[argc] to be NULL - this might
|
||||
@ -4369,7 +4370,8 @@ PHP_FUNCTION(getopt)
|
||||
|
||||
/* Iterate over the hash to construct the argv array. */
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(p_longopts), entry) {
|
||||
zend_string *arg_str = zval_get_string(entry);
|
||||
zend_string *tmp_arg_str;
|
||||
zend_string *arg_str = zval_get_tmp_string(entry, &tmp_arg_str);
|
||||
|
||||
opts->need_param = 0;
|
||||
opts->opt_name = estrdup(ZSTR_VAL(arg_str));
|
||||
@ -4385,7 +4387,7 @@ PHP_FUNCTION(getopt)
|
||||
opts->opt_char = 0;
|
||||
opts++;
|
||||
|
||||
zend_string_release(arg_str);
|
||||
zend_tmp_string_release(tmp_arg_str);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
} else {
|
||||
opts = (opt_struct*) erealloc(opts, sizeof(opt_struct) * (len + 1));
|
||||
|
@ -669,18 +669,19 @@ PHP_FUNCTION(file_put_contents)
|
||||
zval *tmp;
|
||||
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), tmp) {
|
||||
zend_string *str = zval_get_string(tmp);
|
||||
zend_string *t;
|
||||
zend_string *str = zval_get_tmp_string(tmp, &t);
|
||||
if (ZSTR_LEN(str)) {
|
||||
numbytes += ZSTR_LEN(str);
|
||||
bytes_written = php_stream_write(stream, ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
if (bytes_written != ZSTR_LEN(str)) {
|
||||
php_error_docref(NULL, E_WARNING, "Failed to write %zd bytes to %s", ZSTR_LEN(str), filename);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(t);
|
||||
numbytes = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(t);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
break;
|
||||
@ -1936,7 +1937,8 @@ PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char
|
||||
|
||||
count = zend_hash_num_elements(Z_ARRVAL_P(fields));
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(fields), field_tmp) {
|
||||
zend_string *field_str = zval_get_string(field_tmp);
|
||||
zend_string *tmp_field_str;
|
||||
zend_string *field_str = zval_get_tmp_string(field_tmp, &tmp_field_str);
|
||||
|
||||
/* enclose a field that contains a delimiter, an enclosure character, or a newline */
|
||||
if (FPUTCSV_FLD_CHK(delimiter) ||
|
||||
@ -1971,7 +1973,7 @@ PHPAPI size_t php_fputcsv(php_stream *stream, zval *fields, char delimiter, char
|
||||
if (++i != count) {
|
||||
smart_str_appendl(&csvline, &delimiter, 1);
|
||||
}
|
||||
zend_string_release(field_str);
|
||||
zend_tmp_string_release(tmp_field_str);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
smart_str_appendc(&csvline, '\n');
|
||||
|
@ -1210,12 +1210,13 @@ static php_conv_err_t php_conv_get_string_prop_ex(const HashTable *ht, char **pr
|
||||
*pretval_len = 0;
|
||||
|
||||
if ((tmpval = zend_hash_str_find((HashTable *)ht, field_name, field_name_len-1)) != NULL) {
|
||||
zend_string *str = zval_get_string(tmpval);
|
||||
zend_string *tmp;
|
||||
zend_string *str = zval_get_tmp_string(tmpval, &tmp);
|
||||
|
||||
*pretval = pemalloc(ZSTR_LEN(str) + 1, persistent);
|
||||
*pretval_len = ZSTR_LEN(str);
|
||||
memcpy(*pretval, ZSTR_VAL(str), ZSTR_LEN(str) + 1);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp);
|
||||
} else {
|
||||
return PHP_CONV_ERR_NOT_FOUND;
|
||||
}
|
||||
|
@ -564,14 +564,15 @@ php_formatted_print(zend_execute_data *execute_data, int use_array, int format_o
|
||||
tmp = &args[argnum];
|
||||
switch (format[inpos]) {
|
||||
case 's': {
|
||||
zend_string *str = zval_get_string(tmp);
|
||||
zend_string *t;
|
||||
zend_string *str = zval_get_tmp_string(tmp, &t);
|
||||
php_sprintf_appendstring(&result, &outpos,
|
||||
ZSTR_VAL(str),
|
||||
width, precision, padding,
|
||||
alignment,
|
||||
ZSTR_LEN(str),
|
||||
0, expprec, 0);
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(t);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -204,14 +204,15 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
|
||||
default:
|
||||
{
|
||||
zend_string *ekey;
|
||||
zend_string *tmp = zval_get_string(zdata);
|
||||
zend_string *tmp;
|
||||
zend_string *str= zval_get_tmp_string(zdata, &tmp);
|
||||
if (enc_type == PHP_QUERY_RFC3986) {
|
||||
ekey = php_raw_url_encode(ZSTR_VAL(tmp), ZSTR_LEN(tmp));
|
||||
ekey = php_raw_url_encode(ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
} else {
|
||||
ekey = php_url_encode(ZSTR_VAL(tmp), ZSTR_LEN(tmp));
|
||||
ekey = php_url_encode(ZSTR_VAL(str), ZSTR_LEN(str));
|
||||
}
|
||||
smart_str_append(formstr, ekey);
|
||||
zend_string_release(tmp);
|
||||
zend_tmp_string_release(tmp);
|
||||
zend_string_free(ekey);
|
||||
}
|
||||
}
|
||||
|
@ -462,15 +462,15 @@ PHP_FUNCTION(pack)
|
||||
case 'A':
|
||||
case 'Z': {
|
||||
size_t arg_cp = (code != 'Z') ? arg : MAX(0, arg - 1);
|
||||
|
||||
zend_string *str = zval_get_string(&argv[currentarg++]);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(&argv[currentarg++], &tmp_str);
|
||||
|
||||
memset(&ZSTR_VAL(output)[outputpos], (code == 'a' || code == 'Z') ? '\0' : ' ', arg);
|
||||
memcpy(&ZSTR_VAL(output)[outputpos], ZSTR_VAL(str),
|
||||
(ZSTR_LEN(str) < arg_cp) ? ZSTR_LEN(str) : arg_cp);
|
||||
|
||||
outputpos += arg;
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -478,8 +478,8 @@ PHP_FUNCTION(pack)
|
||||
case 'H': {
|
||||
int nibbleshift = (code == 'h') ? 0 : 4;
|
||||
int first = 1;
|
||||
|
||||
zend_string *str = zval_get_string(&argv[currentarg++]);
|
||||
zend_string *tmp_str;
|
||||
zend_string *str = zval_get_tmp_string(&argv[currentarg++], &tmp_str);
|
||||
char *v = ZSTR_VAL(str);
|
||||
|
||||
outputpos--;
|
||||
@ -513,7 +513,7 @@ PHP_FUNCTION(pack)
|
||||
}
|
||||
|
||||
outputpos++;
|
||||
zend_string_release(str);
|
||||
zend_tmp_string_release(tmp_str);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1289,7 +1289,7 @@ PHPAPI void php_implode(const zend_string *glue, zval *pieces, zval *return_valu
|
||||
PHP_FUNCTION(implode)
|
||||
{
|
||||
zval *arg1, *arg2 = NULL, *pieces;
|
||||
zend_string *glue;
|
||||
zend_string *glue, *tmp_glue;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(1, 2)
|
||||
Z_PARAM_ZVAL(arg1)
|
||||
@ -1304,13 +1304,14 @@ PHP_FUNCTION(implode)
|
||||
}
|
||||
|
||||
glue = ZSTR_EMPTY_ALLOC();
|
||||
tmp_glue = NULL;
|
||||
pieces = arg1;
|
||||
} else {
|
||||
if (Z_TYPE_P(arg1) == IS_ARRAY) {
|
||||
glue = zval_get_string(arg2);
|
||||
glue = zval_get_tmp_string(arg2, &tmp_glue);
|
||||
pieces = arg1;
|
||||
} else if (Z_TYPE_P(arg2) == IS_ARRAY) {
|
||||
glue = zval_get_string(arg1);
|
||||
glue = zval_get_tmp_string(arg1, &tmp_glue);
|
||||
pieces = arg2;
|
||||
} else {
|
||||
php_error_docref(NULL, E_WARNING, "Invalid arguments passed");
|
||||
@ -1319,7 +1320,7 @@ PHP_FUNCTION(implode)
|
||||
}
|
||||
|
||||
php_implode(glue, pieces, return_value);
|
||||
zend_string_release(glue);
|
||||
zend_tmp_string_release(tmp_glue);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -2504,7 +2505,7 @@ PHP_FUNCTION(substr_replace)
|
||||
if (Z_TYPE_P(str) != IS_ARRAY) {
|
||||
if (Z_TYPE_P(from) != IS_ARRAY) {
|
||||
zend_string *repl_str;
|
||||
zend_bool repl_release = 0;
|
||||
zend_string *tmp_repl_str = NULL;
|
||||
f = Z_LVAL_P(from);
|
||||
|
||||
/* if "from" position is negative, count start position from the end
|
||||
@ -2545,8 +2546,7 @@ PHP_FUNCTION(substr_replace)
|
||||
repl_idx++;
|
||||
}
|
||||
if (repl_idx < Z_ARRVAL_P(repl)->nNumUsed) {
|
||||
repl_str = zval_get_string(tmp_repl);
|
||||
repl_release = 1;
|
||||
repl_str = zval_get_tmp_string(tmp_repl, &tmp_repl_str);
|
||||
} else {
|
||||
repl_str = STR_EMPTY_ALLOC();
|
||||
}
|
||||
@ -2562,9 +2562,7 @@ PHP_FUNCTION(substr_replace)
|
||||
}
|
||||
memcpy((ZSTR_VAL(result) + f + ZSTR_LEN(repl_str)), Z_STRVAL_P(str) + f + l, Z_STRLEN_P(str) - f - l);
|
||||
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';
|
||||
if (repl_release) {
|
||||
zend_string_release(repl_str);
|
||||
}
|
||||
zend_tmp_string_release(tmp_repl_str);
|
||||
RETURN_NEW_STR(result);
|
||||
} else {
|
||||
php_error_docref(NULL, E_WARNING, "Functionality of 'start' and 'length' as arrays is not implemented");
|
||||
@ -2580,7 +2578,8 @@ PHP_FUNCTION(substr_replace)
|
||||
from_idx = len_idx = repl_idx = 0;
|
||||
|
||||
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(str), num_index, str_index, tmp_str) {
|
||||
zend_string *orig_str = zval_get_string(tmp_str);
|
||||
zend_string *tmp_orig_str;
|
||||
zend_string *orig_str = zval_get_tmp_string(tmp_str, &tmp_orig_str);
|
||||
|
||||
if (Z_TYPE_P(from) == IS_ARRAY) {
|
||||
while (from_idx < Z_ARRVAL_P(from)->nNumUsed) {
|
||||
@ -2659,7 +2658,8 @@ PHP_FUNCTION(substr_replace)
|
||||
repl_idx++;
|
||||
}
|
||||
if (repl_idx < Z_ARRVAL_P(repl)->nNumUsed) {
|
||||
zend_string *repl_str = zval_get_string(tmp_repl);
|
||||
zend_string *tmp_repl_str;
|
||||
zend_string *repl_str = zval_get_tmp_string(tmp_repl, &tmp_repl_str);
|
||||
|
||||
result_len += ZSTR_LEN(repl_str);
|
||||
repl_idx++;
|
||||
@ -2668,7 +2668,7 @@ PHP_FUNCTION(substr_replace)
|
||||
memcpy(ZSTR_VAL(result), ZSTR_VAL(orig_str), f);
|
||||
memcpy((ZSTR_VAL(result) + f), ZSTR_VAL(repl_str), ZSTR_LEN(repl_str));
|
||||
memcpy((ZSTR_VAL(result) + f + ZSTR_LEN(repl_str)), ZSTR_VAL(orig_str) + f + l, ZSTR_LEN(orig_str) - f - l);
|
||||
zend_string_release(repl_str);
|
||||
zend_tmp_string_release(tmp_repl_str);
|
||||
} else {
|
||||
result = zend_string_safe_alloc(1, result_len, 0, 0);
|
||||
|
||||
@ -2696,7 +2696,7 @@ PHP_FUNCTION(substr_replace)
|
||||
add_index_str(return_value, num_index, result);
|
||||
}
|
||||
|
||||
zend_string_release(orig_str);
|
||||
zend_tmp_string_release(tmp_orig_str);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
} /* if */
|
||||
}
|
||||
@ -3083,12 +3083,13 @@ static void php_strtr_array(zval *return_value, zend_string *input, HashTable *p
|
||||
if ((num_bitset[len / sizeof(zend_ulong)] & (Z_UL(1) << (len % sizeof(zend_ulong))))) {
|
||||
entry = zend_hash_str_find(pats, key, len);
|
||||
if (entry != NULL) {
|
||||
zend_string *s = zval_get_string(entry);
|
||||
zend_string *tmp;
|
||||
zend_string *s = zval_get_tmp_string(entry, &tmp);
|
||||
smart_str_appendl(&result, str + old_pos, pos - old_pos);
|
||||
smart_str_append(&result, s);
|
||||
old_pos = pos + len;
|
||||
pos = old_pos - 1;
|
||||
zend_string_release(s);
|
||||
zend_tmp_string_release(tmp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3466,7 +3467,7 @@ PHP_FUNCTION(strtr)
|
||||
RETURN_STR_COPY(str);
|
||||
} else if (zend_hash_num_elements(pats) == 1) {
|
||||
zend_long num_key;
|
||||
zend_string *str_key, *replace;
|
||||
zend_string *str_key, *replace, *tmp_replace;
|
||||
zval *entry, tmp;
|
||||
|
||||
ZEND_HASH_FOREACH_KEY_VAL(pats, num_key, str_key, entry) {
|
||||
@ -3476,7 +3477,7 @@ PHP_FUNCTION(strtr)
|
||||
convert_to_string(&tmp);
|
||||
str_key = Z_STR(tmp);
|
||||
}
|
||||
replace = zval_get_string(entry);
|
||||
replace = zval_get_tmp_string(entry, &tmp_replace);
|
||||
if (ZSTR_LEN(str_key) < 1) {
|
||||
RETVAL_STR_COPY(str);
|
||||
} else if (ZSTR_LEN(str_key) == 1) {
|
||||
@ -3492,7 +3493,7 @@ PHP_FUNCTION(strtr)
|
||||
ZSTR_VAL(str_key), ZSTR_LEN(str_key),
|
||||
ZSTR_VAL(replace), ZSTR_LEN(replace), &dummy));
|
||||
}
|
||||
zend_string_release(replace);
|
||||
zend_tmp_string_release(tmp_replace);
|
||||
zval_dtor(&tmp);
|
||||
return;
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
@ -3945,7 +3946,9 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
|
||||
zval *search_entry,
|
||||
*replace_entry = NULL;
|
||||
zend_string *tmp_result,
|
||||
*replace_entry_str = NULL;
|
||||
*tmp_subject_str,
|
||||
*tmp_replace_entry_str = NULL,
|
||||
*replace_entry_str;
|
||||
char *replace_value = NULL;
|
||||
size_t replace_len = 0;
|
||||
zend_long replace_count = 0;
|
||||
@ -3954,9 +3957,9 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
|
||||
uint32_t replace_idx;
|
||||
|
||||
/* Make sure we're dealing with strings. */
|
||||
subject_str = zval_get_string(subject);
|
||||
subject_str = zval_get_tmp_string(subject, &tmp_subject_str);
|
||||
if (ZSTR_LEN(subject_str) == 0) {
|
||||
zend_string_release(subject_str);
|
||||
zend_tmp_string_release(tmp_subject_str);
|
||||
ZVAL_EMPTY_STRING(result);
|
||||
return 0;
|
||||
}
|
||||
@ -3977,12 +3980,14 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
|
||||
/* For each entry in the search array, get the entry */
|
||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(search), search_entry) {
|
||||
/* Make sure we're dealing with strings. */
|
||||
zend_string *search_str = zval_get_string(search_entry);
|
||||
zend_string *tmp_search_str;
|
||||
zend_string *search_str = zval_get_tmp_string(search_entry, &tmp_search_str);
|
||||
|
||||
if (ZSTR_LEN(search_str) == 0) {
|
||||
if (Z_TYPE_P(replace) == IS_ARRAY) {
|
||||
replace_idx++;
|
||||
}
|
||||
zend_string_release(search_str);
|
||||
zend_tmp_string_release(tmp_search_str);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -3998,7 +4003,7 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
|
||||
}
|
||||
if (replace_idx < Z_ARRVAL_P(replace)->nNumUsed) {
|
||||
/* Make sure we're dealing with strings. */
|
||||
replace_entry_str = zval_get_string(replace_entry);
|
||||
replace_entry_str = zval_get_tmp_string(replace_entry, &tmp_replace_entry_str);
|
||||
|
||||
/* Set replacement value to the one we got from array */
|
||||
replace_value = ZSTR_VAL(replace_entry_str);
|
||||
@ -4045,11 +4050,11 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
|
||||
}
|
||||
}
|
||||
|
||||
zend_string_release(search_str);
|
||||
zend_tmp_string_release(tmp_search_str);
|
||||
|
||||
if (replace_entry_str) {
|
||||
zend_string_release(replace_entry_str);
|
||||
replace_entry_str = NULL;
|
||||
if (tmp_replace_entry_str) {
|
||||
zend_string_release(tmp_replace_entry_str);
|
||||
tmp_replace_entry_str = NULL;
|
||||
}
|
||||
zend_string_release(Z_STR_P(result));
|
||||
ZVAL_STR(result, tmp_result);
|
||||
@ -4058,7 +4063,7 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
|
||||
if (lc_subject_str) {
|
||||
zend_string_release(lc_subject_str);
|
||||
}
|
||||
zend_string_release(subject_str);
|
||||
zend_tmp_string_release(tmp_subject_str);
|
||||
return replace_count;
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
@ -4091,7 +4096,7 @@ static zend_long php_str_replace_in_subject(zval *search, zval *replace, zval *s
|
||||
ZVAL_STR_COPY(result, subject_str);
|
||||
}
|
||||
}
|
||||
zend_string_release(subject_str);
|
||||
zend_tmp_string_release(tmp_subject_str);
|
||||
return replace_count;
|
||||
}
|
||||
/* }}} */
|
||||
@ -4479,7 +4484,7 @@ PHP_FUNCTION(setlocale)
|
||||
{
|
||||
zval *args = NULL;
|
||||
zval *plocale;
|
||||
zend_string *loc;
|
||||
zend_string *loc, *tmp_loc;
|
||||
char *retval;
|
||||
zend_long cat;
|
||||
int num_args, i = 0;
|
||||
@ -4508,15 +4513,15 @@ PHP_FUNCTION(setlocale)
|
||||
plocale = &args[i];
|
||||
}
|
||||
|
||||
loc = zval_get_string(plocale);
|
||||
loc = zval_get_tmp_string(plocale, &tmp_loc);
|
||||
|
||||
if (!strcmp("0", ZSTR_VAL(loc))) {
|
||||
zend_string_release(loc);
|
||||
loc = NULL;
|
||||
zend_tmp_string_release(tmp_loc);
|
||||
tmp_loc = loc = NULL;
|
||||
} else {
|
||||
if (ZSTR_LEN(loc) >= 255) {
|
||||
php_error_docref(NULL, E_WARNING, "Specified locale name is too long");
|
||||
zend_string_release(loc);
|
||||
zend_tmp_string_release(tmp_loc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -4538,19 +4543,17 @@ PHP_FUNCTION(setlocale)
|
||||
RETURN_STR(BG(locale_string));
|
||||
} else {
|
||||
BG(locale_string) = zend_string_init(retval, len, 0);
|
||||
zend_string_release(loc);
|
||||
zend_tmp_string_release(tmp_loc);
|
||||
RETURN_STR_COPY(BG(locale_string));
|
||||
}
|
||||
} else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) {
|
||||
RETURN_STR(loc);
|
||||
}
|
||||
zend_string_release(loc);
|
||||
zend_tmp_string_release(tmp_loc);
|
||||
}
|
||||
RETURN_STRING(retval);
|
||||
}
|
||||
if (loc) {
|
||||
zend_string_release(loc);
|
||||
}
|
||||
zend_tmp_string_release(tmp_loc);
|
||||
|
||||
if (Z_TYPE(args[0]) == IS_ARRAY) {
|
||||
idx++;
|
||||
@ -5141,13 +5144,14 @@ static void php_strnatcmp(INTERNAL_FUNCTION_PARAMETERS, int fold_case)
|
||||
|
||||
PHPAPI int string_natural_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive) /* {{{ */
|
||||
{
|
||||
zend_string *str1 = zval_get_string(op1);
|
||||
zend_string *str2 = zval_get_string(op2);
|
||||
zend_string *tmp_str1, *tmp_str2;
|
||||
zend_string *str1 = zval_get_tmp_string(op1, &tmp_str1);
|
||||
zend_string *str2 = zval_get_tmp_string(op2, &tmp_str2);
|
||||
|
||||
ZVAL_LONG(result, strnatcmp_ex(ZSTR_VAL(str1), ZSTR_LEN(str1), ZSTR_VAL(str2), ZSTR_LEN(str2), case_insensitive));
|
||||
|
||||
zend_string_release(str1);
|
||||
zend_string_release(str2);
|
||||
zend_tmp_string_release(tmp_str1);
|
||||
zend_tmp_string_release(tmp_str2);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -705,7 +705,7 @@ static int php_var_serialize_call_sleep(zval *retval, zval *struc) /* {{{ */
|
||||
static void php_var_serialize_collect_names(HashTable *ht, HashTable *src) /* {{{ */
|
||||
{
|
||||
zval *val;
|
||||
zend_string *name;
|
||||
zend_string *name, *tmp_name;
|
||||
|
||||
zend_hash_init(ht, zend_hash_num_elements(src), NULL, NULL, 0);
|
||||
ZEND_HASH_FOREACH_VAL(src, val) {
|
||||
@ -714,7 +714,7 @@ static void php_var_serialize_collect_names(HashTable *ht, HashTable *src) /* {{
|
||||
"__sleep should return an array only containing the names of instance-variables to serialize.");
|
||||
}
|
||||
|
||||
name = zval_get_string(val);
|
||||
name = zval_get_tmp_string(val, &tmp_name);
|
||||
if (zend_hash_exists(ht, name)) {
|
||||
php_error_docref(NULL, E_NOTICE,
|
||||
"\"%s\" is returned from __sleep multiple times", ZSTR_VAL(name));
|
||||
@ -722,7 +722,7 @@ static void php_var_serialize_collect_names(HashTable *ht, HashTable *src) /* {{
|
||||
continue;
|
||||
}
|
||||
zend_hash_add_empty_element(ht, name);
|
||||
zend_string_release(name);
|
||||
zend_tmp_string_release(tmp_name);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -421,7 +421,7 @@ static void php_wddx_serialize_string(wddx_packet *packet, zval *var)
|
||||
static void php_wddx_serialize_number(wddx_packet *packet, zval *var)
|
||||
{
|
||||
char tmp_buf[WDDX_BUF_LEN], *dec_point;
|
||||
zend_string *str = zval_get_string(var);
|
||||
zend_string *str = zval_get_string_func(var);
|
||||
snprintf(tmp_buf, sizeof(tmp_buf), WDDX_NUMBER, ZSTR_VAL(str));
|
||||
zend_string_release(str);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user