diff --git a/main/streams/streams.c b/main/streams/streams.c index 06589e649c2..bc0b551b520 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1602,12 +1602,10 @@ PHPAPI zend_result _php_stream_copy_to_stream_ex(php_stream *src, php_stream *de * read buffer is empty: we can use copy_file_range() */ int src_fd, dest_fd, dest_open_flags = 0; - /* get dest open flags to check if the stream is open in append mode */ - php_stream_parse_fopen_modes(dest->mode, &dest_open_flags); - /* copy_file_range does not work with O_APPEND */ if (php_stream_cast(src, PHP_STREAM_AS_FD, (void*)&src_fd, 0) == SUCCESS && php_stream_cast(dest, PHP_STREAM_AS_FD, (void*)&dest_fd, 0) == SUCCESS && + /* get dest open flags to check if the stream is open in append mode */ php_stream_parse_fopen_modes(dest->mode, &dest_open_flags) == SUCCESS && !(dest_open_flags & O_APPEND)) {