com php-src: fix leak: ext/phar/tar.c
| From: | Anatol Belski | Date: | Fri, 02 Sep 2016 21:31:26 +0000 |
| Subject: | com php-src: fix leak: ext/phar/tar.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-94262@lists.php.net to get a copy of this message | ||
Commit: 93bb7794332631193e37ade68141c3c39f80c355
Author: Anatol Belski <ab@php.net> Fri, 2 Sep 2016 23:31:26 +0200
Parents: 0b5faa446133609ff92a4d3766da97397f61ff34
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=93bb7794332631193e37ade68141c3c39f80c355
Log:
fix leak
Changed paths:
M ext/phar/tar.c
Diff:
diff --git a/ext/phar/tar.c b/ext/phar/tar.c
index e407397..8386623 100644
--- a/ext/phar/tar.c
+++ b/ext/phar/tar.c
@@ -959,6 +959,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
entry.tar_type = '0';
entry.phar = phar;
entry.fp_type = PHAR_MOD;
+ entry.fp = NULL;
+ entry.filename = NULL;
if (phar->is_persistent) {
if (error) {
@@ -977,6 +979,7 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
entry.filename_len = sizeof(".phar/alias.txt")-1;
entry.fp = php_stream_fopen_tmpfile();
if (entry.fp == NULL) {
+ efree(entry.filename);
spprintf(error, 0, "phar error: unable to create temporary file");
return -1;
}
@@ -984,6 +987,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
if (error) {
spprintf(error, 0, "unable to set alias in tar-based phar \"%s\"",
phar->fname);
}
+ php_stream_close(entry.fp);
+ efree(entry.filename);
return EOF;
}
@@ -993,6 +998,8 @@ int phar_tar_flush(phar_archive_data *phar, char *user_stub, zend_long len, int
if (error) {
spprintf(error, 0, "unable to set alias in tar-based phar \"%s\"",
phar->fname);
}
+ php_stream_close(entry.fp);
+ efree(entry.filename);
return EOF;
}
} else {
@@ -1008,6 +1015,12 @@ 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) {
@@ -1035,6 +1048,12 @@ 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;
@@ -1051,6 +1070,12 @@ 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);