#49727 [Csd]: fclose is not enough to dereference file
| From: | ipseno at yahoo dot com | Date: | Wed, 30 Sep 2009 21:39:14 +0000 |
| Subject: | #49727 [Csd]: fclose is not enough to dereference file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-143094@lists.php.net to get a copy of this message | ||
ID: 49727
User updated by: ipseno at yahoo dot com
Reported By: ipseno at yahoo dot com
Status: Closed
Bug Type: Filesystem function related
Operating System: WIN XP SP3
PHP Version: 5.3SVN-2009-09-30 (snap)
New Comment:
Is it?
Well..., I've reproduced this code/bug with PHP Version 5.3.2-dev,
buiilt at Sep 29 2009 18:56:42
Will then download latest snapshot...
Previous Comments:
------------------------------------------------------------------------
[2009-09-30 19:56:40] iliaa@php.net
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
------------------------------------------------------------------------
[2009-09-30 18:56:16] ipseno at yahoo dot com
Description:
------------
fclose is not enough to dereference file
Reproduce code:
---------------
This WORKED before:
.... php code here ....
// The file that the transfer should be written to, $fp is open file
handle in writing(binary) mode
curl_setopt($this->ch, CURLOPT_FILE, $fp);
// Store image to file
curl_exec($this->ch);
// Close /path/temp/image.tmp
fclose($fp);
// HERE IS A CATCH!
rename(/path/temp/image.tmp, /path/temp/image.tmp.png);
Expected result:
----------------
To rename a file
Actual result:
--------------
NOW, it issues error and DOES NOT rename file:
Warning: rename(/path/temp/image.tmp, /path/temp/image.tmp.png)
[function.rename]: No such file or directory in /path/script.php on line
53536440
FIX: adding unset()!
.... php code here ....
unset($fp);
// HERE IS A CATCH!
rename(/path/temp/image.tmp, /path/temp/image.tmp.png);
Problem: In 5.2 it worked without unset($fp); code line!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49727&edit=1