--- /dev/null
+--TEST--
+Bug #67626: Exceptions not properly handled in user stream handlers
+--FILE--
+<?php
+class MyStream
+{
+ public function stream_open() { return true; }
+
+ public function stream_read()
+ {
+ throw new Exception('stream_read_exception');
+ return 'read';
+ }
+
+ public function stream_eof()
+ {
+ return true;
+ }
+
+ public function stream_write()
+ {
+ throw new Exception('stream_write_exception');
+ return 42;
+ }
+}
+
+stream_wrapper_register("my", "MyStream");
+
+$fp = fopen('my://foobar', 'r+');
+
+try {
+ fread($fp, 42);
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+echo "\n";
+try {
+ fwrite($fp, 'foobar');
+} catch (Exception $e) {
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+stream_read_exception
+stream_write_exception
\ No newline at end of file
zval_ptr_dtor(&func_name);
didwrite = 0;
+
+ if (EG(exception)) {
+ return 0;
+ }
+
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
convert_to_long(&retval);
didwrite = Z_LVAL(retval);
1, args,
0, NULL);
+ zval_ptr_dtor(&args[0);
+ zval_ptr_dtor(&func_name);
+
+ if (EG(exception)) {
+ return -1;
+ }
+
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
convert_to_string(&retval);
didread = Z_STRLEN(retval);
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_READ " is not implemented!",
us->wrapper->classname);
}
- zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&retval);
ZVAL_UNDEF(&retval);
- zval_ptr_dtor(&func_name);
/* since the user stream has no way of setting the eof flag directly, we need to ask it if we hit eof */