Skip to content

Commit f9f841a

Browse files
committed
Fix GH-19922: gzopen() double free
1 parent 266cb7d commit f9f841a

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

main/streams/streams.c

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

22242223
if (opened_path) {
22252224
if (options & STREAM_OPEN_FOR_ZEND_STREAM) {
@@ -2296,8 +2295,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
22962295
if (stream->orig_path) {
22972296
pefree(stream->orig_path, persistent);
22982297
}
2299-
copy_of_path = pestrdup(path, persistent);
2300-
stream->orig_path = copy_of_path;
2298+
stream->orig_path = pestrdup(path, persistent);
23012299
#if ZEND_DEBUG
23022300
stream->open_filename = __zend_orig_filename ? __zend_orig_filename : __zend_filename;
23032301
stream->open_lineno = __zend_orig_lineno ? __zend_orig_lineno : __zend_lineno;
@@ -2356,11 +2354,6 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
23562354
}
23572355
}
23582356
php_stream_tidy_wrapper_error_log(wrapper);
2359-
#if ZEND_DEBUG
2360-
if (stream == NULL && copy_of_path != NULL) {
2361-
pefree(copy_of_path, persistent);
2362-
}
2363-
#endif
23642357
if (resolved_path) {
23652358
zend_string_release_ex(resolved_path, 0);
23662359
}

0 commit comments

Comments
 (0)