@@ -2558,17 +2558,19 @@ ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht,
25582558 return retval ;
25592559}
25602560
2561- static zend_string * zend_find_similar_in_function_table (HashTable * ht , const char * lcname , size_t lcname_len )
2561+ static zend_string * zend_find_similar_in_function_table (const HashTable * ht , const char * lcname , size_t lcname_len )
25622562{
25632563 zend_long threshold = lcname_len >= 8 ? 2 : 1 ;
25642564 zend_long best_dist = threshold + 1 ;
25652565 zend_string * best = NULL ;
2566- zend_string * key ;
2567- zval * val ;
25682566
2569- ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (ht , key , val ) {
2570- if (!key || ZSTR_VAL (key )[0 ] == '\0' ) continue ;
2571- if (llabs ((zend_long )lcname_len - (zend_long )ZSTR_LEN (key )) > threshold ) continue ;
2567+ ZEND_HASH_MAP_FOREACH_STR_KEY_VAL (ht , zend_string * key , zval * val ) {
2568+ if (!key || ZSTR_VAL (key )[0 ] == '\0' ) {
2569+ continue ;
2570+ }
2571+ if (llabs ((zend_long )lcname_len - (zend_long )ZSTR_LEN (key )) > threshold ) {
2572+ continue ;
2573+ }
25722574 zend_long dist = zend_levenshtein (lcname , lcname_len , ZSTR_VAL (key ), ZSTR_LEN (key ));
25732575 if (dist > 0 && dist <= threshold && dist < best_dist ) {
25742576 best_dist = dist ;
@@ -2581,17 +2583,22 @@ static zend_string *zend_find_similar_in_function_table(HashTable *ht, const cha
25812583
25822584static zend_string * zend_find_similar_function (const char * lcname , size_t lcname_len )
25832585{
2584- if (memchr (lcname , '\\' , lcname_len )) return NULL ;
2585- if (lcname_len < 3 ) return NULL ;
2586+ if (memchr (lcname , '\\' , lcname_len )) {
2587+ return NULL ;
2588+ }
2589+ if (lcname_len < 3 ) {
2590+ return NULL ;
2591+ }
25862592 return zend_find_similar_in_function_table (EG (function_table ), lcname , lcname_len );
25872593}
25882594
25892595static zend_string * zend_find_similar_method (const zend_class_entry * ce , const zend_string * method )
25902596{
2591- zend_string * lc_method = zend_string_tolower (( zend_string * ) method );
2597+ zend_string * lc_method = zend_string_alloc ( ZSTR_LEN ( method ), 0 );
25922598 zend_string * best = NULL ;
2599+ zend_str_tolower_copy (ZSTR_VAL (lc_method ), ZSTR_VAL (method ), ZSTR_LEN (method ));
25932600 if (ZSTR_LEN (lc_method ) >= 3 ) {
2594- best = zend_find_similar_in_function_table (( HashTable * ) & ce -> function_table , ZSTR_VAL (lc_method ), ZSTR_LEN (lc_method ));
2601+ best = zend_find_similar_in_function_table (& ce -> function_table , ZSTR_VAL (lc_method ), ZSTR_LEN (lc_method ));
25952602 }
25962603 zend_string_release (lc_method );
25972604 return best ;
0 commit comments