WordPress 4.5
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-filesystem-ftpext.php
index 0a90b9cb306ae680e0d5d0eb43907346ba3424f4..e1202aedd29c9143a5998c52e119c11fddea0263 100644 (file)
@@ -116,12 +116,17 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
                $tempfile = wp_tempnam($file);
                $temp = fopen($tempfile, 'w+');
 
-               if ( ! $temp )
+               if ( ! $temp ) {
+                       unlink( $tempfile );
                        return false;
-
-               if ( ! @ftp_fget($this->link, $temp, $file, FTP_BINARY ) )
+               }
+               
+               if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) {
+                       fclose( $temp );
+                       unlink( $tempfile );
                        return false;
-
+               }
+               
                fseek( $temp, 0 ); // Skip back to the start of the file being written to
                $contents = '';