From 110cf649b7d156f97f98cc8e894fb2d4ed8c67ff Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 29 Oct 2014 13:46:58 +0100 Subject: [PATCH] fix datatype mismatches especially spl_dual_it_object current.pos should have the same datatype as limit.offset, also this doesn't increase the struct size. --- ext/spl/spl_iterators.c | 15 +++++++++------ ext/spl/spl_iterators.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 8b09e3ef37..c129115eeb 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -540,7 +540,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla intern->iterators = emalloc(sizeof(spl_sub_iterator)); intern->level = 0; intern->mode = mode; - intern->flags = flags; + intern->flags = (int)flags; intern->max_depth = -1; intern->in_iteration = 0; intern->ce = Z_OBJCE_P(object); @@ -854,8 +854,11 @@ SPL_METHOD(RecursiveIteratorIterator, setMaxDepth) if (max_depth < -1) { zend_throw_exception(spl_ce_OutOfRangeException, "Parameter max_depth must be >= -1", 0 TSRMLS_CC); return; + } else if (max_depth > INT_MAX) { + max_depth = INT_MAX; } - object->max_depth = max_depth; + + object->max_depth = (int)max_depth; } /* }}} */ /* {{{ proto int|false RecursiveIteratorIterator::getMaxDepth() @@ -1423,9 +1426,9 @@ int spl_dual_it_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS) static inline int spl_dual_it_fetch(spl_dual_it_object *intern, int check_more TSRMLS_DC); -static inline int spl_cit_check_flags(int flags) +static inline int spl_cit_check_flags(zend_long flags) { - int cnt = 0; + zend_long cnt = 0; cnt += (flags & CIT_CALL_TOSTRING) ? 1 : 0; cnt += (flags & CIT_TOSTRING_USE_KEY) ? 1 : 0; @@ -2051,10 +2054,10 @@ SPL_METHOD(RegexIterator, accept) use_copy = zend_make_printable_zval(subject_ptr, &subject_copy TSRMLS_CC); if (use_copy) { subject = Z_STRVAL(subject_copy); - subject_len = Z_STRLEN(subject_copy); + subject_len = (int)Z_STRLEN(subject_copy); } else { subject = Z_STRVAL_P(subject_ptr); - subject_len = Z_STRLEN_P(subject_ptr); + subject_len = (int)Z_STRLEN_P(subject_ptr); } use_copy = 0; diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h index f0740275dc..76f0b45e57 100644 --- a/ext/spl/spl_iterators.h +++ b/ext/spl/spl_iterators.h @@ -134,7 +134,7 @@ typedef struct _spl_dual_it_object { struct { zval data; zval key; - int pos; + zend_long pos; } current; dual_it_type dit_type; union { -- 2.49.0