]> granicus.if.org Git - php/commitdiff
Add test guaranteeing that loop vars are only freed after potential return type excep...
authorBob Weinand <bobwei9@hotmail.com>
Thu, 9 Jul 2015 14:54:41 +0000 (16:54 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Thu, 9 Jul 2015 14:54:41 +0000 (16:54 +0200)
Zend/tests/return_types/029.phpt [new file with mode: 0644]

diff --git a/Zend/tests/return_types/029.phpt b/Zend/tests/return_types/029.phpt
new file mode 100644 (file)
index 0000000..3758745
--- /dev/null
@@ -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