Commit feaa8a10a18 for php

commit feaa8a10a1897c81742edaa2686c02c516780e5e
Merge: a46fadc448d 91452ab11ee
Author: David Carlier <devnexen@gmail.com>
Date:   Fri Nov 20 20:42:57 2026 +0000

    Merge branch 'PHP-8.5' into PHP-8.6

    * PHP-8.5:
      streams: UAF in php_stream_cast() when stream_flush() closes the stream

    # Conflicts:
    #       ext/standard/tests/streams/gh14506.phpt
    #       main/streams/userspace.c

diff --cc ext/standard/tests/streams/gh14506.phpt
index 76d4701160f,05aa2f027d9..a208c83e4c9
--- a/ext/standard/tests/streams/gh14506.phpt
+++ b/ext/standard/tests/streams/gh14506.phpt
@@@ -89,7 -89,8 +89,8 @@@ Warning: fclose(): cannot close the pro
  Warning: fclose(): cannot close the provided stream, as it must not be manually closed in %s on line %d

  Warning: stream_select(): Cannot represent a stream of type user-space as a select()able descriptor in %s on line %d
 -No stream arrays were passed
 +
 +Warning: stream_select(): Cannot represent a stream of type user-space as a select()able descriptor in %s on line %d
 +ValueError: No stream arrays were passed
- TypeError: fclose(): Argument #1 ($stream) must be an open stream resource
+
+ Warning: fclose(): cannot close the provided stream, as it must not be manually closed in %s on line %d
diff --cc main/streams/userspace.c
index a73dd80658a,2bf858060a4..ec8bdcdf0ac
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@@ -741,7 -725,10 +744,10 @@@ static int php_userstreamop_flush(php_s
  	zend_result call_result = zend_call_method_if_exists(Z_OBJ(us->object), func_name, &retval, 0, NULL);
  	zend_string_release_ex(func_name, false);

+ 	stream->flags &= ~PHP_STREAM_FLAG_NO_FCLOSE;
+ 	stream->flags |= orig_no_fclose;
+
 -	int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval) ? 0 : -1;
 +	int ret = call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zend_is_true(&retval) ? 0 : -1;

  	zval_ptr_dtor(&retval);