Skip to content

Commit b34ca99

Browse files
committed
Merge branch 'PHP-8.5'
2 parents 590785e + ed9c1b8 commit b34ca99

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

ext/zlib/tests/gh19922.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
GH-19922 (gzopen double free on debug build and unseekable stream)
3+
--EXTENSIONS--
4+
zlib
5+
--FILE--
6+
<?php
7+
var_dump(gzopen("php://output", 14));
8+
?>
9+
--EXPECTF--
10+
11+
Warning: gzopen(php://output): could not make seekable - php://output in %s on line %d
12+
bool(false)

main/streams/streams.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,7 +2217,6 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
22172217
int persistent = options & STREAM_OPEN_PERSISTENT;
22182218
zend_string *path_str = NULL;
22192219
zend_string *resolved_path = NULL;
2220-
char *copy_of_path = NULL;
22212220

22222221
if (opened_path) {
22232222
if (options & STREAM_OPEN_FOR_ZEND_STREAM) {
@@ -2294,8 +2293,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
22942293
if (stream->orig_path) {
22952294
pefree(stream->orig_path, persistent);
22962295
}
2297-
copy_of_path = pestrdup(path, persistent);
2298-
stream->orig_path = copy_of_path;
2296+
stream->orig_path = pestrdup(path, persistent);
22992297
#if ZEND_DEBUG
23002298
stream->open_filename = __zend_orig_filename ? __zend_orig_filename : __zend_filename;
23012299
stream->open_lineno = __zend_orig_lineno ? __zend_orig_lineno : __zend_lineno;
@@ -2354,11 +2352,6 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
23542352
}
23552353
}
23562354
php_stream_tidy_wrapper_error_log(wrapper);
2357-
#if ZEND_DEBUG
2358-
if (stream == NULL && copy_of_path != NULL) {
2359-
pefree(copy_of_path, persistent);
2360-
}
2361-
#endif
23622355
if (resolved_path) {
23632356
zend_string_release_ex(resolved_path, 0);
23642357
}

0 commit comments

Comments
 (0)