com php-src: fix leaking streams and memory mapped files: ext/phar/phar.c
| From: | Anatol Belski | Date: | Fri, 16 Dec 2016 21:55:02 +0000 |
| Subject: | com php-src: fix leaking streams and memory mapped files: ext/phar/phar.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96346@lists.php.net to get a copy of this message | ||
Commit: 9cdf64c2251a94f7b6bee47d0889e88dbaf5118c
Author: Anatol Belski <ab@php.net> Sun, 11 Dec 2016 02:52:02 +0100
Parents: a32829f909ac64cb2d0a8c8897b61477bfc77e79
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9cdf64c2251a94f7b6bee47d0889e88dbaf5118c
Log:
fix leaking streams and memory mapped files
(cherry picked from commit f1ff23095b1a4fe6d6a65331dda7832ae02eb1a1)
Changed paths:
M ext/phar/phar.c
Diff:
diff --git a/ext/phar/phar.c b/ext/phar/phar.c
index 8159642..c33d6e5 100644
--- a/ext/phar/phar.c
+++ b/ext/phar/phar.c
@@ -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 */