@@ -2212,11 +2212,12 @@ static zend_object *spl_dual_it_new(zend_class_entry *class_type)
2212
2212
static inline int spl_limit_it_valid (spl_dual_it_object * intern )
2213
2213
{
2214
2214
/* FAILURE / SUCCESS */
2215
- if (intern -> u .limit .count != -1 && intern -> current .pos >= intern -> u .limit .offset + intern -> u .limit .count ) {
2215
+ if (intern -> u .limit .count != -1 &&
2216
+ (intern -> current .pos - intern -> u .limit .offset ) >= intern -> u .limit .count ) {
2216
2217
return FAILURE ;
2217
- } else {
2218
- return spl_dual_it_valid (intern );
2219
2218
}
2219
+
2220
+ return spl_dual_it_valid (intern );
2220
2221
}
2221
2222
2222
2223
static inline void spl_limit_it_seek (spl_dual_it_object * intern , zend_long pos )
@@ -2289,7 +2290,7 @@ PHP_METHOD(LimitIterator, valid)
2289
2290
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2290
2291
2291
2292
/* RETURN_BOOL(spl_limit_it_valid(intern) == SUCCESS);*/
2292
- RETURN_BOOL ((intern -> u .limit .count == -1 || intern -> current .pos < intern -> u .limit .offset + intern -> u .limit .count ) && Z_TYPE (intern -> current .data ) != IS_UNDEF );
2293
+ RETURN_BOOL ((intern -> u .limit .count == -1 || ( intern -> current .pos - intern -> u .limit .offset ) < intern -> u .limit .count ) && Z_TYPE (intern -> current .data ) != IS_UNDEF );
2293
2294
} /* }}} */
2294
2295
2295
2296
/* {{{ Move the iterator forward */
@@ -2304,7 +2305,7 @@ PHP_METHOD(LimitIterator, next)
2304
2305
SPL_FETCH_AND_CHECK_DUAL_IT (intern , ZEND_THIS );
2305
2306
2306
2307
spl_dual_it_next (intern , 1 );
2307
- if (intern -> u .limit .count == -1 || intern -> current .pos < intern -> u .limit .offset + intern -> u .limit .count ) {
2308
+ if (intern -> u .limit .count == -1 || ( intern -> current .pos - intern -> u .limit .offset ) < intern -> u .limit .count ) {
2308
2309
spl_dual_it_fetch (intern , 1 );
2309
2310
}
2310
2311
} /* }}} */
0 commit comments