From e7d05c5d0d33fe4ad4a86326ee181f43fd716fd6 Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Wed, 18 Nov 2026 19:57:51 +0200 Subject: [PATCH] tree: Use zend_string accessor macros consistently --- Zend/Optimizer/compact_literals.c | 4 ++-- Zend/zend_gc.c | 2 +- ext/com_dotnet/com_com.c | 2 +- ext/com_dotnet/com_extension.c | 2 +- ext/com_dotnet/com_handlers.c | 2 +- ext/date/php_date.c | 2 +- ext/intl/locale/locale_methods.cpp | 24 +++++++++---------- ext/intl/timezone/timezone_methods.cpp | 6 ++--- ext/opcache/ZendAccelerator.c | 2 +- ext/opcache/jit/zend_jit_helpers.c | 12 +++++----- ext/opcache/jit/zend_jit_ir.c | 4 ++-- ext/soap/php_http.c | 12 +++++----- ext/standard/array.c | 32 +++++++++++++------------- 13 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Zend/Optimizer/compact_literals.c b/Zend/Optimizer/compact_literals.c index 6ed7e870da61..8b534aa8f899 100644 --- a/Zend/Optimizer/compact_literals.c +++ b/Zend/Optimizer/compact_literals.c @@ -255,8 +255,8 @@ void zend_optimizer_compact_literals(zend_op_array *op_array, zend_optimizer_ctx #if DEBUG_COMPACT_LITERALS { - fprintf(stderr, "File %s func %s\n", op_array->filename->val, - op_array->function_name ? op_array->function_name->val : "main"); + fprintf(stderr, "File %s func %s\n", ZSTR_VAL(op_array->filename), + op_array->function_name ? ZSTR_VAL(op_array->function_name) : "main"); fprintf(stderr, "Literals table size %d\n", op_array->last_literal); for (uint32_t i = 0; i < op_array->last_literal; i++) { diff --git a/Zend/zend_gc.c b/Zend/zend_gc.c index 944c03bb3965..dfe36e41b018 100644 --- a/Zend/zend_gc.c +++ b/Zend/zend_gc.c @@ -481,7 +481,7 @@ static void gc_trace_ref(zend_refcounted *ref) { fprintf(stderr, "[%p] rc=%d addr=%d %s object(%s)#%d ", ref, GC_REFCOUNT(ref), GC_REF_ADDRESS(ref), gc_color_name(GC_REF_COLOR(ref)), - obj->ce->name->val, obj->handle); + ZSTR_VAL(obj->ce->name), obj->handle); } else if (GC_TYPE(ref) == IS_ARRAY) { zend_array *arr = (zend_array *) ref; fprintf(stderr, "[%p] rc=%d addr=%d %s array(%d) ", diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 85886f20bc07..8997ecf4e626 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -471,7 +471,7 @@ zend_result php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_fu if (FAILED(hr)) { char *msg = NULL; char *winerr = php_win32_error_to_msg(hr); - spprintf(&msg, 0, "Unable to lookup `%s': %s", f->function_name->val, winerr); + spprintf(&msg, 0, "Unable to lookup `%s': %s", ZSTR_VAL(f->function_name), winerr); php_win32_error_msg_free(winerr); php_com_throw_exception(hr, msg); efree(msg); diff --git a/ext/com_dotnet/com_extension.c b/ext/com_dotnet/com_extension.c index e9c6e46884ce..a01e6f759499 100644 --- a/ext/com_dotnet/com_extension.c +++ b/ext/com_dotnet/com_extension.c @@ -89,7 +89,7 @@ static PHP_INI_MH(OnTypeLibFileUpdate) char *typelib_name_buffer; char *strtok_buf = NULL; - if (NULL == new_value || !new_value->val[0] || (typelib_file = VCWD_FOPEN(new_value->val, "r"))==NULL) { + if (NULL == new_value || !ZSTR_VAL(new_value)[0] || (typelib_file = VCWD_FOPEN(ZSTR_VAL(new_value), "r"))==NULL) { return FAILURE; } diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index e4b187b3c98d..0cd46deafc22 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -321,7 +321,7 @@ static zend_function *com_method_get(zend_object **object_ptr, zend_string *name int i; if (SUCCEEDED(ITypeInfo_GetTypeComp(obj->typeinfo, &comp))) { - olename = php_com_string_to_olestring(name->val, name->len, obj->code_page); + olename = php_com_string_to_olestring(ZSTR_VAL(name), ZSTR_LEN(name), obj->code_page); lhash = LHashValOfNameSys(SYS_WIN32, LOCALE_NEUTRAL, olename); if (SUCCEEDED(ITypeComp_Bind(comp, olename, lhash, INVOKE_FUNC, &TI, &kind, &bindptr))) { diff --git a/ext/date/php_date.c b/ext/date/php_date.c index c44a608875a7..8c4e122af8db 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1351,7 +1351,7 @@ PHPAPI void php_strftime(INTERNAL_FUNCTION_PARAMETERS, bool gmt) /* VS2012 strftime() returns number of characters, not bytes. See VC++11 bug id 766205. */ if (real_len > 0) { - real_len = strlen(buf->val); + real_len = strlen(ZSTR_VAL(buf)); } #endif diff --git a/ext/intl/locale/locale_methods.cpp b/ext/intl/locale/locale_methods.cpp index 76fa7c2ac6d8..ceb9e9e027cd 100644 --- a/ext/intl/locale/locale_methods.cpp +++ b/ext/intl/locale/locale_methods.cpp @@ -1142,7 +1142,7 @@ static int add_array_entry(const char* loc_name, zval* hash_arr, const char* key if( result > 0 && key_value){ int cnt = 0; /* Tokenize on the "_" or "-" */ - token = php_strtok_r( key_value->val , DELIMITER ,&last_ptr); + token = php_strtok_r( ZSTR_VAL(key_value) , DELIMITER ,&last_ptr); /* Over-allocates a few bytes for the integer so we don't have to reallocate. */ size_t cur_key_name_size = (sizeof("-2147483648") - 1) + strlen(key_name) + 1; cur_key_name.reset(reinterpret_cast(emalloc(cur_key_name_size))); @@ -1242,7 +1242,7 @@ PHP_INTL_FUNCTION_WITH_ERROR_RESET(locale_get_all_variants) variant = get_icu_value_internal( loc_name , LOC_VARIANT_TAG , &result ,0); if( result > 0 && variant){ /* Tokenize on the "_" or "-" */ - token = php_strtok_r( variant->val , DELIMITER , &saved_ptr); + token = php_strtok_r( ZSTR_VAL(variant) , DELIMITER , &saved_ptr); add_next_index_stringl( return_value, token , strlen(token)); /* tokenize on the "_" or "-" and stop at singleton if any */ while( (token = php_strtok_r(nullptr , DELIMITER, &saved_ptr)) && (strlen(token)>1) ){ @@ -1348,19 +1348,19 @@ PHP_INTL_FUNCTION_WITH_ERROR_RESET(locale_filter_matches) } /* Convert to lower case for case-insensitive comparison */ - cur_lang_tag = std::unique_ptr(reinterpret_cast(ecalloc(can_lang_tag->len + 1, sizeof(char)))); + cur_lang_tag = std::unique_ptr(reinterpret_cast(ecalloc(ZSTR_LEN(can_lang_tag) + 1, sizeof(char)))); char *p_cur_lang_tag = cur_lang_tag.get(); /* Convert to lower case for case-insensitive comparison */ - result = strToMatch( can_lang_tag->val , p_cur_lang_tag); + result = strToMatch( ZSTR_VAL(can_lang_tag) , p_cur_lang_tag); if( result == 0) { zend_string_release_ex( can_lang_tag, false ); RETURN_FALSE; } - cur_loc_range = std::unique_ptr(reinterpret_cast(ecalloc(can_loc_range->len + 1, sizeof(char)))); + cur_loc_range = std::unique_ptr(reinterpret_cast(ecalloc(ZSTR_LEN(can_loc_range) + 1, sizeof(char)))); char *p_cur_loc_range = cur_loc_range.get(); - result = strToMatch( can_loc_range->val , p_cur_loc_range ); + result = strToMatch( ZSTR_VAL(can_loc_range) , p_cur_loc_range ); if( result == 0) { zend_string_release_ex( can_lang_tag, false ); zend_string_release_ex( can_loc_range, false ); @@ -1372,7 +1372,7 @@ PHP_INTL_FUNCTION_WITH_ERROR_RESET(locale_filter_matches) if( token && (token==p_cur_lang_tag) ){ /* check if the char. after match is SEPARATOR */ - chrcheck = token + can_loc_range->len; + chrcheck = token + ZSTR_LEN(can_loc_range); if( isIDSeparator(*chrcheck) || isKeywordSeparator(*chrcheck) || isEndOfTag(*chrcheck) ){ zend_string_release_ex( can_lang_tag, false ); zend_string_release_ex( can_loc_range, false ); @@ -1479,15 +1479,15 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr, if(canonicalize) { for(i=0; ival[0]) { + if(result != 1 || lang_tag == nullptr || !ZSTR_VAL(lang_tag)[0]) { if(lang_tag) { zend_string_release_ex(lang_tag, 0); } intl_error_set(nullptr, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag"); LOOKUP_CLEAN_RETURN(nullptr); } - cur_arr[i*2] = reinterpret_cast(erealloc(cur_arr[i*2], lang_tag->len+1)); - result = strToMatch(lang_tag->val, cur_arr[i*2]); + cur_arr[i*2] = reinterpret_cast(erealloc(cur_arr[i*2], ZSTR_LEN(lang_tag)+1)); + result = strToMatch(ZSTR_VAL(lang_tag), cur_arr[i*2]); zend_string_release_ex(lang_tag, 0); if(result == 0) { intl_error_set(nullptr, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize lang_tag"); @@ -1500,7 +1500,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr, if(canonicalize) { /* Canonicalize the loc_range */ can_loc_range = get_icu_value_internal(loc_range, LOC_CANONICALIZE_TAG, &result , 0); - if( result != 1 || can_loc_range == nullptr || !can_loc_range->val[0]) { + if( result != 1 || can_loc_range == nullptr || !ZSTR_VAL(can_loc_range)[0]) { /* Error */ intl_error_set(nullptr, U_ILLEGAL_ARGUMENT_ERROR, "unable to canonicalize loc_range"); if(can_loc_range) { @@ -1508,7 +1508,7 @@ static zend_string* lookup_loc_range(const char* loc_range, HashTable* hash_arr, } LOOKUP_CLEAN_RETURN(nullptr); } else { - loc_range = can_loc_range->val; + loc_range = ZSTR_VAL(can_loc_range); } } diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index 89d725217b90..6c0c0ed7b98f 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -581,7 +581,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_windows_id) ZEND_PARSE_PARAMETERS_END(); error = U_ZERO_ERROR; - if (intl_stringFromChar(uID, id->val, id->len, &error) == FAILURE) { + if (intl_stringFromChar(uID, ZSTR_VAL(id), ZSTR_LEN(id), &error) == FAILURE) { intl_error_set(NULL, error, "could not convert time zone id to UTF-16"); RETURN_FALSE; @@ -619,14 +619,14 @@ U_CFUNC PHP_FUNCTION(intltz_get_id_for_windows_id) ZEND_PARSE_PARAMETERS_END(); error = U_ZERO_ERROR; - if (intl_stringFromChar(uWinID, winID->val, winID->len, &error) == FAILURE) { + if (intl_stringFromChar(uWinID, ZSTR_VAL(winID), ZSTR_LEN(winID), &error) == FAILURE) { intl_error_set(NULL, error, "could not convert time zone id to UTF-16"); RETURN_FALSE; } error = U_ZERO_ERROR; - TimeZone::getIDForWindowsID(uWinID, region ? region->val : NULL, uID, error); + TimeZone::getIDForWindowsID(uWinID, region ? ZSTR_VAL(region) : NULL, uID, error); INTL_CHECK_STATUS(error, "unable to get windows ID for timezone"); if (uID.length() == 0) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index 43d65de65f41..f5756e8be9be 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -1156,7 +1156,7 @@ static accel_time_t zend_get_file_handle_timestamp_win(zend_file_handle *file_ha utc_base = (((unsigned __int64)utc_base_ft.dwHighDateTime) << 32) + utc_base_ft.dwLowDateTime; } - if (file_handle->opened_path && GetFileAttributesEx(file_handle->opened_path->val, GetFileExInfoStandard, &fdata) != 0) { + if (file_handle->opened_path && GetFileAttributesEx(ZSTR_VAL(file_handle->opened_path), GetFileExInfoStandard, &fdata) != 0) { unsigned __int64 ftime; if (CompareFileTime (&fdata.ftLastWriteTime, &utc_base_ft) < 0) { diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index 2f801a6623d1..97136a5cd112 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -309,7 +309,7 @@ static zend_execute_data* ZEND_FASTCALL zend_jit_int_extend_stack_helper(uint32_ static zval* ZEND_FASTCALL zend_jit_symtable_find(HashTable *ht, zend_string *str) { zend_ulong idx; - register const char *tmp = str->val; + register const char *tmp = ZSTR_VAL(str); do { if (*tmp > '9') { @@ -323,7 +323,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_find(HashTable *ht, zend_string *st break; } } - if (_zend_handle_numeric_str_ex(str->val, str->len, &idx)) { + if (_zend_handle_numeric_str_ex(ZSTR_VAL(str), ZSTR_LEN(str), &idx)) { return zend_hash_index_find(ht, idx); } } while (0); @@ -367,7 +367,7 @@ static zval* ZEND_FASTCALL zend_jit_hash_lookup_rw(HashTable *ht, zend_string *s static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_string *str) { zend_ulong idx; - register const char *tmp = str->val; + register const char *tmp = ZSTR_VAL(str); zval *retval; do { @@ -382,7 +382,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_strin break; } } - if (_zend_handle_numeric_str_ex(str->val, str->len, &idx)) { + if (_zend_handle_numeric_str_ex(ZSTR_VAL(str), ZSTR_LEN(str), &idx)) { retval = zend_hash_index_find(ht, idx); if (!retval) { retval = zend_undefined_offset_write(ht, idx); @@ -402,7 +402,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_strin static zval* ZEND_FASTCALL zend_jit_symtable_lookup_w(HashTable *ht, zend_string *str) { zend_ulong idx; - register const char *tmp = str->val; + register const char *tmp = ZSTR_VAL(str); do { if (*tmp > '9') { @@ -416,7 +416,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_lookup_w(HashTable *ht, zend_string break; } } - if (_zend_handle_numeric_str_ex(str->val, str->len, &idx)) { + if (_zend_handle_numeric_str_ex(ZSTR_VAL(str), ZSTR_LEN(str), &idx)) { return zend_hash_index_lookup(ht, idx); } } while (0); diff --git a/ext/opcache/jit/zend_jit_ir.c b/ext/opcache/jit/zend_jit_ir.c index ea7ed81d5f18..f71fd287ee25 100644 --- a/ext/opcache/jit/zend_jit_ir.c +++ b/ext/opcache/jit/zend_jit_ir.c @@ -888,7 +888,7 @@ static ir_ref jit_EMALLOC(zend_jit_ctx *jit, size_t size, const zend_op_array *o #if ZEND_DEBUG return ir_CALL_5(IR_ADDR, ir_CONST_FC_FUNC(_emalloc), ir_CONST_ADDR(size), - op_array->filename ? ir_CONST_ADDR(op_array->filename->val) : IR_NULL, + op_array->filename ? ir_CONST_ADDR(ZSTR_VAL(op_array->filename)) : IR_NULL, ir_CONST_U32(opline ? opline->lineno : 0), IR_NULL, ir_CONST_U32(0)); @@ -908,7 +908,7 @@ static ir_ref jit_EFREE(zend_jit_ctx *jit, ir_ref ptr, size_t size, const zend_o #if ZEND_DEBUG return ir_CALL_5(IR_ADDR, ir_CONST_FC_FUNC(_efree), ptr, - op_array && op_array->filename ? ir_CONST_ADDR(op_array->filename->val) : IR_NULL, + op_array && op_array->filename ? ir_CONST_ADDR(ZSTR_VAL(op_array->filename)) : IR_NULL, ir_CONST_U32(opline ? opline->lineno : 0), IR_NULL, ir_CONST_U32(0)); diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index b4b368cfeadd..13bbdae5dd85 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -704,7 +704,7 @@ bool make_http_soap_request( } } smart_str_append_const(&soap_headers,"Content-Length: "); - smart_str_append_long(&soap_headers, request->len); + smart_str_append_long(&soap_headers, ZSTR_LEN(request)); smart_str_append_const(&soap_headers, "\r\n"); /* HTTP Authentication */ @@ -1555,7 +1555,7 @@ static zend_string* get_http_body(php_stream *stream, bool close, zend_string *h } while (len_size < buf_size) { - ssize_t len_read = php_stream_read(stream, http_buf->val + http_buf_size, buf_size - len_size); + ssize_t len_read = php_stream_read(stream, ZSTR_VAL(http_buf) + http_buf_size, buf_size - len_size); if (UNEXPECTED(len_read <= 0)) { /* Error or EOF */ done = true; @@ -1616,7 +1616,7 @@ static zend_string* get_http_body(php_stream *stream, bool close, zend_string *h return NULL; } while (http_buf_size < header_length) { - ssize_t len_read = php_stream_read(stream, http_buf->val + http_buf_size, header_length - http_buf_size); + ssize_t len_read = php_stream_read(stream, ZSTR_VAL(http_buf) + http_buf_size, header_length - http_buf_size); if (UNEXPECTED(len_read <= 0)) { zend_string_efree(http_buf); return NULL; @@ -1640,7 +1640,7 @@ static zend_string* get_http_body(php_stream *stream, bool close, zend_string *h } else { http_buf = zend_string_alloc(4096, 0); } - len_read = php_stream_read(stream, http_buf->val + http_buf_size, 4096); + len_read = php_stream_read(stream, ZSTR_VAL(http_buf) + http_buf_size, 4096); if (len_read > 0) { http_buf_size += len_read; } @@ -1649,8 +1649,8 @@ static zend_string* get_http_body(php_stream *stream, bool close, zend_string *h return NULL; } - http_buf->val[http_buf_size] = '\0'; - http_buf->len = http_buf_size; + ZSTR_VAL(http_buf)[http_buf_size] = '\0'; + ZSTR_LEN(http_buf) = http_buf_size; return http_buf; } diff --git a/ext/standard/array.c b/ext/standard/array.c index fe5d7cfd55e5..55504cb06c64 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -149,12 +149,12 @@ static zend_always_inline int php_array_key_compare_numeric_unstable_i(Bucket *f } else { double d1, d2; if (f->key) { - d1 = zend_strtod(f->key->val, NULL); + d1 = zend_strtod(ZSTR_VAL(f->key), NULL); } else { d1 = (double)(zend_long)f->h; } if (s->key) { - d2 = zend_strtod(s->key->val, NULL); + d2 = zend_strtod(ZSTR_VAL(s->key), NULL); } else { d2 = (double)(zend_long)s->h; } @@ -171,15 +171,15 @@ static zend_always_inline int php_array_key_compare_string_case_unstable_i(Bucke char buf2[MAX_LENGTH_OF_LONG + 1]; if (f->key) { - s1 = f->key->val; - l1 = f->key->len; + s1 = ZSTR_VAL(f->key); + l1 = ZSTR_LEN(f->key); } else { s1 = zend_print_long_to_buf(buf1 + sizeof(buf1) - 1, f->h); l1 = buf1 + sizeof(buf1) - 1 - s1; } if (s->key) { - s2 = s->key->val; - l2 = s->key->len; + s2 = ZSTR_VAL(s->key); + l2 = ZSTR_LEN(s->key); } else { s2 = zend_print_long_to_buf(buf2 + sizeof(buf2) - 1, s->h); l2 = buf2 + sizeof(buf2) - 1 - s2; @@ -196,15 +196,15 @@ static zend_always_inline int php_array_key_compare_string_unstable_i(Bucket *f, char buf2[MAX_LENGTH_OF_LONG + 1]; if (f->key) { - s1 = f->key->val; - l1 = f->key->len; + s1 = ZSTR_VAL(f->key); + l1 = ZSTR_LEN(f->key); } else { s1 = zend_print_long_to_buf(buf1 + sizeof(buf1) - 1, f->h); l1 = buf1 + sizeof(buf1) - 1 - s1; } if (s->key) { - s2 = s->key->val; - l2 = s->key->len; + s2 = ZSTR_VAL(s->key); + l2 = ZSTR_LEN(s->key); } else { s2 = zend_print_long_to_buf(buf2 + sizeof(buf2) - 1, s->h); l2 = buf2 + sizeof(buf2) - 1 - s2; @@ -221,15 +221,15 @@ static int php_array_key_compare_string_natural_general(Bucket *f, Bucket *s, bo char buf2[MAX_LENGTH_OF_LONG + 1]; if (f->key) { - s1 = f->key->val; - l1 = f->key->len; + s1 = ZSTR_VAL(f->key); + l1 = ZSTR_LEN(f->key); } else { s1 = zend_print_long_to_buf(buf1 + sizeof(buf1) - 1, f->h); l1 = buf1 + sizeof(buf1) - 1 - s1; } if (s->key) { - s2 = s->key->val; - l2 = s->key->len; + s2 = ZSTR_VAL(s->key); + l2 = ZSTR_LEN(s->key); } else { s2 = zend_print_long_to_buf(buf2 + sizeof(buf2) - 1, s->h); l2 = buf2 + sizeof(buf2) - 1 - s2; @@ -269,12 +269,12 @@ static zend_always_inline int php_array_key_compare_string_locale_unstable_i(Buc char buf2[MAX_LENGTH_OF_LONG + 1]; if (f->key) { - s1 = f->key->val; + s1 = ZSTR_VAL(f->key); } else { s1 = zend_print_long_to_buf(buf1 + sizeof(buf1) - 1, f->h); } if (s->key) { - s2 = s->key->val; + s2 = ZSTR_VAL(s->key); } else { s2 = zend_print_long_to_buf(buf2 + sizeof(buf2) - 1, s->h); }