#28627 [Opn->Csd]: php_mysql_set_default_link leaks ref
| From: | iliaa@php.net | Date: | Fri, 04 Jun 2004 13:49:48 +0000 |
| Subject: | #28627 [Opn->Csd]: php_mysql_set_default_link leaks ref | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-60361@lists.php.net to get a copy of this message | ||
ID: 28627
Updated by: iliaa@php.net
Reported By: gavin at ipalsoftware dot com
-Status: Open
+Status: Closed
Bug Type: MySQL related
Operating System: all
PHP Version: 4.3.6
New Comment:
This bug has been fixed in CVS.
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.
Previous Comments:
------------------------------------------------------------------------
[2004-06-03 23:31:16] gavin at ipalsoftware dot com
Description:
------------
In php_mysql.c:
/* {{{ php_mysql_set_default_link
*/
static void php_mysql_set_default_link(int id TSRMLS_DC)
{
MySG(default_link) = id;
zend_list_addref(id);
}
/* }}} */
if MySG(default_link) is already set (!= -1), the above code needs to
deref it before setting the default_link. Otherwise a mysql_close down
the road on the original default_link will not actually close the
connection (it has too many references now).
Reproduce code:
---------------
A possible patch:
--- php-4.3.6.orig/ext/mysql/php_mysql.c 2004-06-03
16:08:29.124642476 -0500
+++ php-4.3.6/ext/mysql/php_mysql.c 2004-06-03 16:13:21.192405843
-0500
@@ -259,6 +259,9 @@
*/
static void php_mysql_set_default_link(int id TSRMLS_DC)
{
+ if (MySG(default_link)!=-1) {
+ zend_list_delete(MySG(default_link));
+ }
MySG(default_link) = id;
zend_list_addref(id);
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28627&edit=1