From 96cc419924c38874f9e2f2e5ccf3cd0430d90f43 Mon Sep 17 00:00:00 2001 From: Philip Hofstetter Date: Wed, 2 Oct 2013 08:35:02 +0200 Subject: Fix bug #65667: ftp_nb_continue produces segfault the idea behind ftp_nb_get is for it to be followed by multiple calls to ftp_nb_continue in order to download a file piece-by-piece. As such, it's unwise to close the stream used to write the downloaded data to when the file hasn't been completely downloaded within the first call to ftp_nb_get. This regression was added in a93a462dcefd62e07963dd2da506fbb3409c88b5 and this patch restores the behavior that was seen pre-patch. --- ext/ftp/php_ftp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ext/ftp/php_ftp.c') diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index da22e0b63e..21e13ea460 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -968,7 +968,9 @@ PHP_FUNCTION(ftp_nb_get) RETURN_LONG(PHP_FTP_FAILED); } - php_stream_close(outstream); + if (ret == PHP_FTP_FINISHED){ + php_stream_close(outstream); + } RETURN_LONG(ret); } -- cgit v1.2.1