@@ -1020,6 +1020,10 @@ PHP_FUNCTION(end)
1020
1020
ZEND_PARSE_PARAMETERS_END ();
1021
1021
1022
1022
HashTable * array = get_ht_for_iap (array_zv , /* separate */ true);
1023
+ if (zend_hash_num_elements (array ) == 0 ) {
1024
+ /* array->nInternalPointer is already 0 if the array is empty, even after removing elements */
1025
+ RETURN_FALSE ;
1026
+ }
1023
1027
zend_hash_internal_pointer_end (array );
1024
1028
1025
1029
if (USED_RET ()) {
@@ -1047,6 +1051,10 @@ PHP_FUNCTION(prev)
1047
1051
ZEND_PARSE_PARAMETERS_END ();
1048
1052
1049
1053
HashTable * array = get_ht_for_iap (array_zv , /* separate */ true);
1054
+ if (zend_hash_num_elements (array ) == 0 ) {
1055
+ /* array->nInternalPointer is already 0 if the array is empty, even after removing elements */
1056
+ RETURN_FALSE ;
1057
+ }
1050
1058
zend_hash_move_backwards (array );
1051
1059
1052
1060
if (USED_RET ()) {
@@ -1074,6 +1082,10 @@ PHP_FUNCTION(next)
1074
1082
ZEND_PARSE_PARAMETERS_END ();
1075
1083
1076
1084
HashTable * array = get_ht_for_iap (array_zv , /* separate */ true);
1085
+ if (zend_hash_num_elements (array ) == 0 ) {
1086
+ /* array->nInternalPointer is already 0 if the array is empty, even after removing elements */
1087
+ RETURN_FALSE ;
1088
+ }
1077
1089
zend_hash_move_forward (array );
1078
1090
1079
1091
if (USED_RET ()) {
@@ -1101,6 +1113,10 @@ PHP_FUNCTION(reset)
1101
1113
ZEND_PARSE_PARAMETERS_END ();
1102
1114
1103
1115
HashTable * array = get_ht_for_iap (array_zv , /* separate */ true);
1116
+ if (zend_hash_num_elements (array ) == 0 ) {
1117
+ /* array->nInternalPointer is already 0 if the array is empty, even after removing elements */
1118
+ RETURN_FALSE ;
1119
+ }
1104
1120
zend_hash_internal_pointer_reset (array );
1105
1121
1106
1122
if (USED_RET ()) {
0 commit comments