]> granicus.if.org Git - php/commitdiff
Fixed bug #46031 (Segfault in AppendIterator::next)
authorArnaud Le Blanc <lbarnaud@php.net>
Tue, 9 Sep 2008 19:43:52 +0000 (19:43 +0000)
committerArnaud Le Blanc <lbarnaud@php.net>
Tue, 9 Sep 2008 19:43:52 +0000 (19:43 +0000)
ext/spl/spl_iterators.c
ext/spl/tests/bug46031.phpt [new file with mode: 0644]

index ce27ee7d7b88ee7d58368a1b3139d4b1815ebdd1..e6bfea84500dece3c4bb9a123622b319af17e9b9 100755 (executable)
@@ -1499,6 +1499,9 @@ static inline void spl_dual_it_rewind(spl_dual_it_object *intern TSRMLS_DC)
 
 static inline int spl_dual_it_valid(spl_dual_it_object *intern TSRMLS_DC)
 {
+       if (!intern->inner.iterator) {
+               return FAILURE;
+       }
        /* FAILURE / SUCCESS */
        return intern->inner.iterator->funcs->valid(intern->inner.iterator TSRMLS_CC);
 }
diff --git a/ext/spl/tests/bug46031.phpt b/ext/spl/tests/bug46031.phpt
new file mode 100644 (file)
index 0000000..9261ff0
--- /dev/null
@@ -0,0 +1,9 @@
+--TEST--
+Bug #46031 (Segfault in AppendIterator::next)
+--FILE--
+<?php
+$x = new AppendIterator();
+var_dump($x->next());
+?>
+--EXPECT--
+NULL