@@ -614,6 +614,7 @@ ZEND_API int zend_hash_rehash(HashTable *ht)
614
614
615
615
static zend_always_inline void _zend_hash_del_el_ex (HashTable * ht , uint32_t idx , Bucket * p , Bucket * prev )
616
616
{
617
+ HANDLE_BLOCK_INTERRUPTIONS ();
617
618
if (!(ht -> u .flags & HASH_FLAG_PACKED )) {
618
619
if (prev ) {
619
620
Z_NEXT (prev -> val ) = Z_NEXT (p -> val );
@@ -650,6 +651,7 @@ static zend_always_inline void _zend_hash_del_el_ex(HashTable *ht, uint32_t idx,
650
651
} else {
651
652
ZVAL_UNDEF (& p -> val );
652
653
}
654
+ HANDLE_UNBLOCK_INTERRUPTIONS ();
653
655
}
654
656
655
657
static zend_always_inline void _zend_hash_del_el (HashTable * ht , uint32_t idx , Bucket * p )
@@ -697,9 +699,7 @@ ZEND_API int zend_hash_del(HashTable *ht, zend_string *key)
697
699
p -> key &&
698
700
p -> key -> len == key -> len &&
699
701
memcmp (p -> key -> val , key -> val , key -> len ) == 0 )) {
700
- HANDLE_BLOCK_INTERRUPTIONS ();
701
702
_zend_hash_del_el_ex (ht , idx , p , prev );
702
- HANDLE_UNBLOCK_INTERRUPTIONS ();
703
703
return SUCCESS ;
704
704
}
705
705
prev = p ;
@@ -745,9 +745,7 @@ ZEND_API int zend_hash_del_ind(HashTable *ht, zend_string *key)
745
745
ZVAL_UNDEF (data );
746
746
}
747
747
} else {
748
- HANDLE_BLOCK_INTERRUPTIONS ();
749
748
_zend_hash_del_el_ex (ht , idx , p , prev );
750
- HANDLE_UNBLOCK_INTERRUPTIONS ();
751
749
}
752
750
return SUCCESS ;
753
751
}
@@ -793,9 +791,7 @@ ZEND_API int zend_hash_str_del(HashTable *ht, const char *str, size_t len)
793
791
ZVAL_UNDEF (data );
794
792
}
795
793
} else {
796
- HANDLE_BLOCK_INTERRUPTIONS ();
797
794
_zend_hash_del_el_ex (ht , idx , p , prev );
798
- HANDLE_UNBLOCK_INTERRUPTIONS ();
799
795
}
800
796
return SUCCESS ;
801
797
}
@@ -825,9 +821,7 @@ ZEND_API int zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len)
825
821
&& p -> key
826
822
&& (p -> key -> len == len )
827
823
&& !memcmp (p -> key -> val , str , len )) {
828
- HANDLE_BLOCK_INTERRUPTIONS ();
829
824
_zend_hash_del_el_ex (ht , idx , p , prev );
830
- HANDLE_UNBLOCK_INTERRUPTIONS ();
831
825
return SUCCESS ;
832
826
}
833
827
prev = p ;
@@ -849,9 +843,7 @@ ZEND_API int zend_hash_index_del(HashTable *ht, zend_ulong h)
849
843
if (h < ht -> nNumUsed ) {
850
844
p = ht -> arData + h ;
851
845
if (Z_TYPE (p -> val ) != IS_UNDEF ) {
852
- HANDLE_BLOCK_INTERRUPTIONS ();
853
846
_zend_hash_del_el_ex (ht , h , p , NULL );
854
- HANDLE_UNBLOCK_INTERRUPTIONS ();
855
847
return SUCCESS ;
856
848
}
857
849
}
@@ -863,9 +855,7 @@ ZEND_API int zend_hash_index_del(HashTable *ht, zend_ulong h)
863
855
while (idx != INVALID_IDX ) {
864
856
p = ht -> arData + idx ;
865
857
if ((p -> h == h ) && (p -> key == NULL )) {
866
- HANDLE_BLOCK_INTERRUPTIONS ();
867
858
_zend_hash_del_el_ex (ht , idx , p , prev );
868
- HANDLE_UNBLOCK_INTERRUPTIONS ();
869
859
return SUCCESS ;
870
860
}
871
861
prev = p ;
@@ -1041,20 +1031,6 @@ ZEND_API void zend_symtable_clean(HashTable *ht)
1041
1031
}
1042
1032
}
1043
1033
1044
- /* This function is used by the various apply() functions.
1045
- * It deletes the passed bucket, and returns the address of the
1046
- * next bucket. The hash *may* be altered during that time, the
1047
- * returned value will still be valid.
1048
- */
1049
- static void zend_hash_apply_deleter (HashTable * ht , uint32_t idx , Bucket * p )
1050
- {
1051
-
1052
- HANDLE_BLOCK_INTERRUPTIONS ();
1053
- _zend_hash_del_el (ht , idx , p );
1054
- HANDLE_UNBLOCK_INTERRUPTIONS ();
1055
- }
1056
-
1057
-
1058
1034
ZEND_API void zend_hash_graceful_destroy (HashTable * ht )
1059
1035
{
1060
1036
uint32_t idx ;
@@ -1065,7 +1041,7 @@ ZEND_API void zend_hash_graceful_destroy(HashTable *ht)
1065
1041
for (idx = 0 ; idx < ht -> nNumUsed ; idx ++ ) {
1066
1042
p = ht -> arData + idx ;
1067
1043
if (Z_TYPE (p -> val ) == IS_UNDEF ) continue ;
1068
- zend_hash_apply_deleter (ht , idx , p );
1044
+ _zend_hash_del_el (ht , idx , p );
1069
1045
}
1070
1046
if (ht -> nTableMask ) {
1071
1047
pefree (ht -> arData , ht -> u .flags & HASH_FLAG_PERSISTENT );
@@ -1086,7 +1062,7 @@ ZEND_API void zend_hash_graceful_reverse_destroy(HashTable *ht)
1086
1062
idx -- ;
1087
1063
p = ht -> arData + idx ;
1088
1064
if (Z_TYPE (p -> val ) == IS_UNDEF ) continue ;
1089
- zend_hash_apply_deleter (ht , idx , p );
1065
+ _zend_hash_del_el (ht , idx , p );
1090
1066
}
1091
1067
1092
1068
if (ht -> nTableMask ) {
@@ -1121,7 +1097,7 @@ ZEND_API void zend_hash_apply(HashTable *ht, apply_func_t apply_func)
1121
1097
result = apply_func (& p -> val );
1122
1098
1123
1099
if (result & ZEND_HASH_APPLY_REMOVE ) {
1124
- zend_hash_apply_deleter (ht , idx , p );
1100
+ _zend_hash_del_el (ht , idx , p );
1125
1101
}
1126
1102
if (result & ZEND_HASH_APPLY_STOP ) {
1127
1103
break ;
@@ -1147,7 +1123,7 @@ ZEND_API void zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t appl
1147
1123
result = apply_func (& p -> val , argument );
1148
1124
1149
1125
if (result & ZEND_HASH_APPLY_REMOVE ) {
1150
- zend_hash_apply_deleter (ht , idx , p );
1126
+ _zend_hash_del_el (ht , idx , p );
1151
1127
}
1152
1128
if (result & ZEND_HASH_APPLY_STOP ) {
1153
1129
break ;
@@ -1179,7 +1155,7 @@ ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t ap
1179
1155
result = apply_func (& p -> val , num_args , args , & hash_key );
1180
1156
1181
1157
if (result & ZEND_HASH_APPLY_REMOVE ) {
1182
- zend_hash_apply_deleter (ht , idx , p );
1158
+ _zend_hash_del_el (ht , idx , p );
1183
1159
}
1184
1160
if (result & ZEND_HASH_APPLY_STOP ) {
1185
1161
va_end (args );
@@ -1210,7 +1186,7 @@ ZEND_API void zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func)
1210
1186
result = apply_func (& p -> val );
1211
1187
1212
1188
if (result & ZEND_HASH_APPLY_REMOVE ) {
1213
- zend_hash_apply_deleter (ht , idx , p );
1189
+ _zend_hash_del_el (ht , idx , p );
1214
1190
}
1215
1191
if (result & ZEND_HASH_APPLY_STOP ) {
1216
1192
break ;
@@ -1932,25 +1908,15 @@ ZEND_API zval *zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint
1932
1908
ZEND_API int _zend_handle_numeric_str_ex (const char * key , size_t length , zend_ulong * idx )
1933
1909
{
1934
1910
register const char * tmp = key ;
1935
- const char * end ;
1936
1911
1937
- if (* tmp > '9' ) {
1938
- return 0 ;
1939
- } else if (* tmp < '0' ) {
1940
- if (* tmp != '-' ) {
1941
- return 0 ;
1942
- }
1912
+ const char * end = key + length ;
1913
+ ZEND_ASSERT (* end == '\0' );
1914
+
1915
+ if (* tmp == '-' ) {
1943
1916
tmp ++ ;
1944
- if (* tmp > '9' || * tmp < '0' ) {
1945
- return 0 ;
1946
- }
1947
1917
}
1948
1918
1949
- /* possibly a numeric index */
1950
- end = key + length ;
1951
-
1952
- if ((* end != '\0' ) /* not a null terminated string */
1953
- || (* tmp == '0' && length > 1 ) /* numbers with leading zeros */
1919
+ if ((* tmp == '0' && length > 1 ) /* numbers with leading zeros */
1954
1920
|| (end - tmp > MAX_LENGTH_OF_LONG - 1 ) /* number too long */
1955
1921
|| (SIZEOF_ZEND_LONG == 4 &&
1956
1922
end - tmp == MAX_LENGTH_OF_LONG - 1 &&
0 commit comments