WordPress.org

Make WordPress Core

Changeset 38094


Ignore:
Timestamp:
07/18/2016 07:42:48 PM (4 years ago)
Author:
ocean90
Message:

Filesystem API: Cleanup temporary file when the temporary file couldn't be opened.

Props ruud@joyo.
See #34772.
Fixes #36942, #36943.

Location:
trunk/src/wp-admin/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php

    r35944 r38094  
    121121            return false;
    122122        }
    123        
     123
    124124        if ( ! @ftp_fget( $this->link, $temp, $file, FTP_BINARY ) ) {
    125125            fclose( $temp );
     
    127127            return false;
    128128        }
    129        
     129
    130130        fseek( $temp, 0 ); // Skip back to the start of the file being written to
    131131        $contents = '';
     
    160160        $tempfile = wp_tempnam($file);
    161161        $temp = fopen( $tempfile, 'wb+' );
    162         if ( ! $temp )
    163             return false;
     162
     163        if ( ! $temp ) {
     164            unlink( $tempfile );
     165            return false;
     166        }
    164167
    165168        mbstring_binary_safe_encoding();
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r35944 r38094  
    122122        $temp = wp_tempnam( $file );
    123123
    124         if ( ! $temphandle = fopen($temp, 'w+') )
    125             return false;
     124        if ( ! $temphandle = fopen( $temp, 'w+' ) ) {
     125            unlink( $temp );
     126            return false;
     127        }
    126128
    127129        mbstring_binary_safe_encoding();
Note: See TracChangeset for help on using the changeset viewer.