com php-src: Fix leak caused by fix to bug #65667: ext/ftp/ftp.c ext/ftp/php_ftp.c
| From: | Nikita Popov | Date: | Mon, 30 Dec 2013 12:53:12 +0000 |
| Subject: | com php-src: Fix leak caused by fix to bug #65667: ext/ftp/ftp.c ext/ftp/php_ftp.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75505@lists.php.net to get a copy of this message | ||
Commit: 3b6afb1bd63ef92f9914867f04bedeea90e21789
Author: Nikita Popov <nikic@php.net> Mon, 30 Dec 2013 13:46:55 +0100
Parents: 8e5048f9fb93846846e82c42c39f1759c97a73c2
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3b6afb1bd63ef92f9914867f04bedeea90e21789
Log:
Fix leak caused by fix to bug #65667
ftp->stream is now closed in the ftp resource dtor.
Bugs:
https://bugs.php.net/65667
Changed paths:
M ext/ftp/ftp.c
M ext/ftp/php_ftp.c
Diff:
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index b82017e..fce9ecf 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -178,6 +178,10 @@ ftp_close(ftpbuf_t *ftp)
if (ftp->data) {
data_close(ftp, ftp->data);
}
+ if (ftp->stream && ftp->closestream) {
+ TSRMLS_FETCH();
+ php_stream_close(ftp->stream);
+ }
if (ftp->fd != -1) {
#if HAVE_OPENSSL_EXT
if (ftp->ssl_active) {
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c
index 21e13ea..99f3808 100644
--- a/ext/ftp/php_ftp.c
+++ b/ext/ftp/php_ftp.c
@@ -963,6 +963,7 @@ PHP_FUNCTION(ftp_nb_get)
if ((ret = ftp_nb_get(ftp, outstream, remote, xtype, resumepos TSRMLS_CC)) == PHP_FTP_FAILED) {
php_stream_close(outstream);
+ ftp->stream = NULL;
VCWD_UNLINK(local);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ftp->inbuf);
RETURN_LONG(PHP_FTP_FAILED);
@@ -970,6 +971,7 @@ PHP_FUNCTION(ftp_nb_get)
if (ret == PHP_FTP_FINISHED){
php_stream_close(outstream);
+ ftp->stream = NULL;
}
RETURN_LONG(ret);
@@ -1003,6 +1005,7 @@ PHP_FUNCTION(ftp_nb_continue)
if (ret != PHP_FTP_MOREDATA && ftp->closestream) {
php_stream_close(ftp->stream);
+ ftp->stream = NULL;
}
if (ret == PHP_FTP_FAILED) {
@@ -1214,6 +1217,7 @@ PHP_FUNCTION(ftp_nb_put)
if (ret != PHP_FTP_MOREDATA) {
php_stream_close(instream);
+ ftp->stream = NULL;
}
if (ret == PHP_FTP_FAILED) {