mirror of
https://github.com/php/php-src.git
synced 2025-08-17 22:48:57 +02:00
fix leaking streams and memory mapped files
(cherry picked from commit f1ff23095b
)
This commit is contained in:
parent
a32829f909
commit
9cdf64c225
1 changed files with 19 additions and 7 deletions
|
@ -3270,19 +3270,31 @@ static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type)
|
|||
|
||||
/* zip or tar-based phar */
|
||||
spprintf(&name, 4096, "phar://%s/%s", file_handle->filename, ".phar/stub.php");
|
||||
if (SUCCESS == phar_orig_zend_open((const char *)name, file_handle)) {
|
||||
if (SUCCESS == phar_orig_zend_open((const char *)name, &f)) {
|
||||
|
||||
efree(name);
|
||||
name = NULL;
|
||||
file_handle->filename = f.filename;
|
||||
if (file_handle->opened_path) {
|
||||
efree(file_handle->opened_path);
|
||||
|
||||
f.filename = file_handle->filename;
|
||||
if (f.opened_path) {
|
||||
efree(f.opened_path);
|
||||
}
|
||||
f.opened_path = file_handle->opened_path;
|
||||
f.free_filename = file_handle->free_filename;
|
||||
|
||||
switch (file_handle->type) {
|
||||
case ZEND_HANDLE_STREAM:
|
||||
case ZEND_HANDLE_MAPPED:
|
||||
if (file_handle->handle.stream.closer && file_handle->handle.stream.handle) {
|
||||
file_handle->handle.stream.closer(file_handle->handle.stream.handle);
|
||||
}
|
||||
file_handle->handle.stream.handle = NULL;
|
||||
break;
|
||||
}
|
||||
file_handle->opened_path = f.opened_path;
|
||||
file_handle->free_filename = f.free_filename;
|
||||
} else {
|
||||
*file_handle = f;
|
||||
}
|
||||
} else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) {
|
||||
zend_file_handle_dtor(file_handle);
|
||||
/* compressed phar */
|
||||
file_handle->type = ZEND_HANDLE_STREAM;
|
||||
/* we do our own reading directly from the phar, don't change the next line */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue