Skip to content

Commit 390a294

Browse files
Filesystem API: Avoid a fatal error in PclZip when the temporary file cannot be created.
`PclZip::privExtractFileUsingTempFile()` calls `fclose( $v_file )` when it fails to open its temporary file, but `$v_file` is not defined in that function. On PHP 8, `fclose( null )` throws a `TypeError`, so the request dies with a fatal error instead of returning an error with `PCLZIP_ERR_WRITE_OPEN_FAIL`. Nothing has been opened at that point, so the call is removed. The similar `fclose( $v_file )` in `privAddFileUsingTempFile()` is correct (the file is opened a few lines above) and is left unchanged. Developed in #15133. Follow-up to r11056. Props ExtremsX. Fixes #66408. git-svn-id: https://develop.svn.wordpress.org/trunk@65003 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e0b5e00 commit 390a294

1 file changed

Lines changed: 0 additions & 1 deletion

File tree

‎src/wp-admin/includes/class-pclzip.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3981,7 +3981,6 @@ function privExtractFileUsingTempFile(&$p_entry, &$p_options)
39813981
// ----- Creates a temporary file
39823982
$v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
39833983
if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3984-
fclose($v_file);
39853984
PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
39863985
return PclZip::errorCode();
39873986
}

0 commit comments

Comments
 (0)