#41871 [Opn->Bgs]: mysql_free_result does not free result for a referenced result variable
| From: | sniper@php.net | Date: | Mon, 02 Jul 2007 23:11:17 +0000 |
| Subject: | #41871 [Opn->Bgs]: mysql_free_result does not free result for a referenced result variable | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114551@lists.php.net to get a copy of this message | ||
ID: 41871
Updated by: sniper@php.net
Reported By: kulakov74 at yandex dot ru
-Status: Open
+Status: Bogus
Bug Type: MySQL related
Operating System: Linux / Windows
PHP Version: 5.2.3
New Comment:
This is expected result. mysql_free_result() just decreases the
refcount to the result and actual freeing happens during request
shutdown (if refcount to the result is 0!).
Previous Comments:
------------------------------------------------------------------------
[2007-07-02 13:12:53] kulakov74 at yandex dot ru
Description:
------------
When I call mysql_free_result($Res) I expect I won't be able to use the
result in calls to mysql_fetch_array() etc. But if $Res is passed by
reference as a function parameter and is copied to another variable the
result is not freed and I can still use it.
I realize this is a VERY unlikely condition and I found it by accident
(mixed 2 lines of code and got surprised to see no error). Also this
might well be intentional behavior. Anyway, just in case.
Reproduce code:
---------------
a($Res);
function a(&$Res){
$Res=mysql_query("Show Tables"); $Res1=$Res;
mysql_free_result($Res);
mysql_fetch_array($Res); //still works!
}
Expected result:
----------------
Warning: mysql_fetch_array(): 7 is not a valid MySQL result resource in
Actual result:
--------------
No errors
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41871&edit=1