Commit bb5fcf7fbe4 for php

commit bb5fcf7fbe45993ab1de97b4be0f468702a1daec
Merge: df4bff20204 50e5acdd4ba
Author: David Carlier <devnexen@gmail.com>
Date:   Sun Nov 29 12:24:08 2026 +0000

    Merge branch 'PHP-8.6'

    * PHP-8.6:
      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 ceb9e9e027c,37b3407c33e..e0f8c0d256f
--- a/ext/intl/locale/locale_methods.cpp
+++ b/ext/intl/locale/locale_methods.cpp
@@@ -1140,19 -1189,21 +1140,21 @@@ 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);
 +			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<char *>(emalloc(cur_key_name_size)));
- 			char *p_cur_key_name = cur_key_name.get();
- 			snprintf( p_cur_key_name, cur_key_name_size , "%s%d", key_name , cnt++);
- 			add_assoc_string( hash_arr, p_cur_key_name , token);
- 			/* tokenize on the "_" or "-" and stop  at singleton if any */
- 			while( (token = php_strtok_r(nullptr , DELIMITER , &last_ptr)) && (strlen(token)>1) ){
- 				snprintf( p_cur_key_name , cur_key_name_size, "%s%d", key_name , cnt++);
+ 			if (token) {
+ 				int cnt = 0;
+ 				/* 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<char *>(emalloc(cur_key_name_size)));
+ 				char *p_cur_key_name = cur_key_name.get();
+ 				snprintf( p_cur_key_name, cur_key_name_size , "%s%d", key_name , cnt++);
  				add_assoc_string( hash_arr, p_cur_key_name , token);
+ 				/* tokenize on the "_" or "-" and stop  at singleton if any */
+ 				while( (token = php_strtok_r(nullptr , DELIMITER , &last_ptr)) && (strlen(token)>1) ){
+ 					snprintf( p_cur_key_name , cur_key_name_size, "%s%d", key_name , cnt++);
+ 					add_assoc_string( hash_arr, p_cur_key_name , token);
+ 				}
  			}
  /*
  			if( strcmp(key_name, LOC_PRIVATE_TAG) == 0 ){
@@@ -1242,11 -1293,13 +1244,13 @@@ PHP_INTL_FUNCTION_WITH_ERROR_RESET(loca
  		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) ){
+ 			if (token) {
  				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) ){
+ 					add_next_index_stringl( return_value, token , strlen(token));
+ 				}
  			}
  		}
  		if( variant ){