com php-src: fix erroneous resource destruction: ext/phar/tar.c
| From: | Anatol Belski | Date: | Wed, 14 Sep 2016 10:07:38 +0000 |
| Subject: | com php-src: fix erroneous resource destruction: ext/phar/tar.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94509@lists.php.net to get a copy of this message | ||
Commit: 001fbbb94f6a182e9db1ddcbad73ce7f4076f117
Author: Anatol Belski <ab@php.net> Wed, 14 Sep 2016 12:07:38 +0200
Parents: acc574d76b60d23b48f8fa561084eb859c2e0766
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=001fbbb94f6a182e9db1ddcbad73ce7f4076f117
Log:
fix erroneous resource destruction
Changed paths:
M ext/phar/tar.c
Diff:
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index b3dfad8..3a60191 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -1002,6 +1002,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len,
int
efree(entry.filename);
return EOF;
}
+ /* At this point the entry is saved into the manifest. The manifest destroy
+ routine will care about any resources to be freed. */
} else {
zend_hash_str_del(&phar->manifest, ".phar/alias.txt",
sizeof(".phar/alias.txt")-1);
}
@@ -1015,12 +1017,6 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len,
int
if (error) {
spprintf(error, 0, "unable to access resource to copy stub to new tar-based phar
\"%s\"", phar->fname);
}
- if (entry.fp) {
- php_stream_close(entry.fp);
- }
- if (entry.filename) {
- efree(entry.filename);
- }
return EOF;
}
if (len == -1) {
@@ -1048,12 +1044,6 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len,
int
if (error) {
spprintf(error, 0, "unable to read resource to copy stub to new tar-based phar
\"%s\"", phar->fname);
}
- if (entry.fp) {
- php_stream_close(entry.fp);
- }
- if (entry.filename) {
- efree(entry.filename);
- }
return EOF;
}
free_user_stub = 1;
@@ -1070,12 +1060,6 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len,
int
if (free_user_stub) {
efree(user_stub);
}
- if (entry.fp) {
- php_stream_close(entry.fp);
- }
- if (entry.filename) {
- efree(entry.filename);
- }
return EOF;
}
pos = user_stub + (pos - tmp);