scottmac                Sat May  9 19:35:10 2009 UTC

  Modified files:              (Branch: PHP_5_3)
    /php-src/ext/spl    spl_iterators.c 
  Log:
  MFH Fix bug #48206 - Iterating over an invalid data structure leads to a 
segfault
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.c?r1=1.73.2.30.2.28.2.22&r2=1.73.2.30.2.28.2.23&diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.73.2.30.2.28.2.22 
php-src/ext/spl/spl_iterators.c:1.73.2.30.2.28.2.23
--- php-src/ext/spl/spl_iterators.c:1.73.2.30.2.28.2.22 Tue Jan 20 00:43:25 2009
+++ php-src/ext/spl/spl_iterators.c     Sat May  9 19:35:09 2009
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c,v 1.73.2.30.2.28.2.22 2009/01/20 00:43:25 felipe Exp $ 
*/
+/* $Id: spl_iterators.c,v 1.73.2.30.2.28.2.23 2009/05/09 19:35:09 scottmac Exp 
$ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -922,7 +922,9 @@
        iterator->funcs->get_current_data(iterator, &data TSRMLS_CC);
 
        zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, 
&error_handling TSRMLS_CC);
-       RETVAL_ZVAL(*data, 1, 0);
+       if (data && *data) {
+               RETVAL_ZVAL(*data, 1, 0);
+       }
        if (Z_TYPE_P(return_value) == IS_ARRAY) {
                zval_dtor(return_value);
                ZVAL_STRINGL(return_value, "Array", sizeof("Array")-1, 1);
@@ -1006,7 +1008,11 @@
                zval                      **data;
 
                iterator->funcs->get_current_data(iterator, &data TSRMLS_CC);
-               RETURN_ZVAL(*data, 1, 0);
+               if (data && *data) {
+                       RETURN_ZVAL(*data, 1, 0);
+               } else {
+                       RETURN_NULL();
+               }
        }
 
        spl_recursive_tree_iterator_get_prefix(object, &prefix TSRMLS_CC);
@@ -2729,7 +2735,9 @@
 
        intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() 
TSRMLS_CC);
        intern->inner.iterator->funcs->get_current_data(intern->inner.iterator, 
&data TSRMLS_CC);
-       RETURN_ZVAL(*data, 1, 0);
+       if (data && *data) {
+               RETURN_ZVAL(*data, 1, 0);
+       }
 } /* }}} */
 
 /* {{{ proto void NoRewindIterator::next()
@@ -3041,6 +3049,9 @@
        if (EG(exception)) {
                return ZEND_HASH_APPLY_STOP;
        }
+       if (data == NULL || *data == NULL) {
+               return ZEND_HASH_APPLY_STOP;
+       }
        if (iter->funcs->get_current_key) {
                key_type = iter->funcs->get_current_key(iter, &str_key, 
&str_key_len, &int_key TSRMLS_CC);
                if (EG(exception)) {
@@ -3072,6 +3083,9 @@
        if (EG(exception)) {
                return ZEND_HASH_APPLY_STOP;
        }
+       if (data == NULL || *data == NULL) {
+               return ZEND_HASH_APPLY_STOP;
+       }
        Z_ADDREF_PP(data);
        add_next_index_zval(return_value, *data);
        return ZEND_HASH_APPLY_KEEP;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to