Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Bugfix #26229 (getIterator() segfaults when it returns arrays or sc…

…alars)
  • Loading branch information...
commit 82193adc09d7f107fcfedcb544b5a8f76e1dc33f 1 parent 14e54cd
Marcus Boerger authored
View
16 Zend/tests/bug26229.phpt
@@ -11,11 +11,19 @@ class array_iterator implements IteratorAggregate {
$obj = new array_iterator;
-foreach ($obj as $property => $value) {
- var_dump($value);
+try
+{
+ foreach ($obj as $property => $value)
+ {
+ var_dump($value);
+ }
+}
+catch(Exception $e)
+{
+ echo $e->getMessage() . "\n";
}
?>
===DONE===
--EXPECTF--
-Warning: Objects returned by array_iterator::getIterator() must be traversable or implement interface Iterator in %sbug26229.php on line %d
-===DONE===
+Objects returned by array_iterator::getIterator() must be traversable or implement interface Iterator
+===DONE===
View
3  Zend/zend_interfaces.c
@@ -21,6 +21,7 @@
#include "zend.h"
#include "zend_API.h"
#include "zend_interfaces.h"
+#include "zend_exceptions.h"
ZEND_API zend_class_entry *zend_ce_traversable;
ZEND_API zend_class_entry *zend_ce_aggregate;
@@ -275,7 +276,7 @@ static zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce,
if (!ce || !ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && iterator == object)) {
if (!EG(exception))
{
- zend_error(E_WARNING, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce->name);
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce->name);
}
if (iterator)
{
View
3  Zend/zend_vm_def.h
@@ -2872,6 +2872,9 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
} else {
FREE_OP1_IF_VAR();
}
+ if (!EG(exception)) {
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name);
+ }
zend_throw_exception_internal(NULL TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
}
View
15 Zend/zend_vm_execute.h
@@ -1968,6 +1968,9 @@ static int ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else {
;
}
+ if (!EG(exception)) {
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name);
+ }
zend_throw_exception_internal(NULL TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
}
@@ -4384,6 +4387,9 @@ static int ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else {
;
}
+ if (!EG(exception)) {
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name);
+ }
zend_throw_exception_internal(NULL TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
}
@@ -7462,6 +7468,9 @@ static int ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else {
if (free_op1.var) {zval_ptr_dtor(&free_op1.var);};
}
+ if (!EG(exception)) {
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name);
+ }
zend_throw_exception_internal(NULL TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
}
@@ -18238,6 +18247,9 @@ static int ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else {
;
}
+ if (!EG(exception)) {
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name);
+ }
zend_throw_exception_internal(NULL TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
}
@@ -30537,6 +30549,9 @@ static int ZEND_FE_RESET_HANDLER(ZEND_OPCODE_HANDLER_ARGS)
} else {
FREE_OP_IF_VAR(free_op1);
}
+ if (!EG(exception)) {
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Object of type %s did not create an Iterator", ce->name);
+ }
zend_throw_exception_internal(NULL TSRMLS_CC);
ZEND_VM_NEXT_OPCODE();
}
Please sign in to comment.
Something went wrong with that request. Please try again.