Commit cd16f66d331 for php
commit cd16f66d331fa94e234ff79e1483e1bae1d1d625
Merge: 94b93214ec5 f868473e5be
Author: David Carlier <devnexen@gmail.com>
Date: Sun Nov 29 12:23:23 2026 +0000
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
ext/intl: Fix NULL deref in locale_parse() and locale_get_all_variants()
# Conflicts:
# ext/intl/locale/locale_methods.cpp
diff --cc ext/intl/locale/locale_methods.cpp
index 13347722db9,5b223bb1c51..d3df381c11e
--- a/ext/intl/locale/locale_methods.cpp
+++ b/ext/intl/locale/locale_methods.cpp
@@@ -1074,21 -1076,23 +1074,23 @@@ static int add_array_entry(const char*
if( (strcmp(key_name , LOC_PRIVATE_TAG)==0) ||
( strcmp(key_name , LOC_VARIANT_TAG)==0) ){
if( result > 0 && key_value){
- int cnt = 0;
/* Tokenize on the "_" or "-" */
token = php_strtok_r( key_value->val , DELIMITER ,&last_ptr);
- if( cur_key_name ){
- efree( cur_key_name);
- }
- /* 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 = reinterpret_cast<char *>(emalloc(cur_key_name_size));
- snprintf( cur_key_name, cur_key_name_size , "%s%d", key_name , cnt++);
- add_assoc_string( hash_arr, cur_key_name , token);
- /* tokenize on the "_" or "-" and stop at singleton if any */
- while( (token = php_strtok_r(NULL , DELIMITER , &last_ptr)) && (strlen(token)>1) ){
- snprintf( cur_key_name , cur_key_name_size, "%s%d", key_name , cnt++);
+ if (token) {
+ int cnt = 0;
+ if( cur_key_name ){
+ efree( cur_key_name);
+ }
+ /* 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 = emalloc(cur_key_name_size);
++ cur_key_name = reinterpret_cast<char *>(emalloc(cur_key_name_size));
+ snprintf( cur_key_name, cur_key_name_size , "%s%d", key_name , cnt++);
add_assoc_string( hash_arr, cur_key_name , token);
+ /* tokenize on the "_" or "-" and stop at singleton if any */
+ while( (token = php_strtok_r(NULL , DELIMITER , &last_ptr)) && (strlen(token)>1) ){
+ snprintf( cur_key_name , cur_key_name_size, "%s%d", key_name , cnt++);
+ add_assoc_string( hash_arr, cur_key_name , token);
+ }
}
/*
if( strcmp(key_name, LOC_PRIVATE_TAG) == 0 ){