PHP :: Bug #28627 :: php_mysql_set_default_link leaks ref
| Bug #28627 | php_mysql_set_default_link leaks ref | ||||
|---|---|---|---|---|---|
| Submitted: | 2004-06-03 23:31 UTC | Modified: | 2004-06-04 15:49 UTC | ||
| From: | gavin at ipalsoftware dot com | Assigned: | |||
| Status: | Closed | Package: | MySQL related | ||
| PHP Version: | 4.3.6 | OS: | all | ||
| Private report: | No | CVE-ID: | None | ||
[2004-06-03 23:31 UTC] 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);
}
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-06-04 15:49 UTC] iliaa@php.net