summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2015-07-09 16:54:41 +0200
committerBob Weinand <bobwei9@hotmail.com>2015-07-09 16:54:41 +0200
commitf5db5a558d550bf441373febebbb02f3884209d1 (patch)
treeaa8283ce649f5e7fc438374f736a26dd27049aff
parent54f367ee2a2e4cb7c952b17915c226fdc56038ab (diff)
downloadphp-git-f5db5a558d550bf441373febebbb02f3884209d1.tar.gz
Add test guaranteeing that loop vars are only freed after potential return type exceptions
-rw-r--r--Zend/tests/return_types/029.phpt19
1 files changed, 19 insertions, 0 deletions
diff --git a/Zend/tests/return_types/029.phpt b/Zend/tests/return_types/029.phpt
new file mode 100644
index 0000000000..37587452f5
--- /dev/null
+++ b/Zend/tests/return_types/029.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Return types must not double free loop variables
+--FILE--
+<?php
+
+function foo(): string {
+ foreach ([new stdClass] as $class) {
+ try {
+ return $class; // invalid return type
+ } catch (TypeError $e) {
+ return "no leak or segfault";
+ }
+ }
+}
+print foo();
+
+?>
+--EXPECT--
+no leak or segfault