summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2005-03-19 15:09:11 +0000
committerMarcus Boerger <helly@php.net>2005-03-19 15:09:11 +0000
commitfec49370525625ba110439c1cf32320e948766bb (patch)
tree942329bbd989f00d05116cd675ab33a274ca620f /ext/spl
parentcf020f133487d36a8b1d9cfd16ec456f7f07952e (diff)
downloadphp-git-fec49370525625ba110439c1cf32320e948766bb.tar.gz
- Add new test
Diffstat (limited to 'ext/spl')
-rwxr-xr-xext/spl/tests/bug31185.phpt57
1 files changed, 57 insertions, 0 deletions
diff --git a/ext/spl/tests/bug31185.phpt b/ext/spl/tests/bug31185.phpt
new file mode 100755
index 0000000000..edd90f5b47
--- /dev/null
+++ b/ext/spl/tests/bug31185.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Bug #31185 (Crash when exceptions thrown from ArrayAccess::offsetUnset())
+--FILE--
+<?php
+
+class FooBar implements ArrayAccess {
+ private $array = array();
+
+ public function offsetExists($index) {
+ return isset($this->array[$index]);
+ }
+
+ public function offsetGet($index) {
+ return $this->array[$index];
+ }
+
+ public function offsetSet($index, $value) {
+ $this->array[$index] = $value;
+ }
+
+ public function offsetUnset($index) {
+ throw new Exception('FAIL');
+ unset($this->array[$index]);
+ }
+
+}
+
+$i = 0;
+$foo = new FooBar();
+$foo[$i] = $i++;
+$foo[$i] = $i++;
+$foo[$i] = $i++;
+try
+{
+ unset($foo[1]);
+}
+catch (Exception $e)
+{
+ echo "CAUGHT: " . $e->getMessage() . "\n";
+}
+
+print_R($foo);
+?>
+===DONE===
+--EXPECT--
+CAUGHT: FAIL
+FooBar Object
+(
+ [array:private] => Array
+ (
+ [1] => 0
+ [2] => 1
+ [3] => 2
+ )
+
+)
+===DONE===