PHP :: Bug #23187 :: Memory leak in sybase_connect/sybase_pconnect
| Bug #23187 | Memory leak in sybase_connect/sybase_pconnect | ||||
|---|---|---|---|---|---|
| Submitted: | 2003-04-13 09:24 UTC | Modified: | 2003-04-14 20:00 UTC | ||
| From: | fukusaka at xa2 dot so-net dot ne dot jp | Assigned: | |||
| Status: | Closed | Package: | Sybase (dblib) related | ||
| PHP Version: | 4CVS-2003-04-13 (stable) | OS: | Linux 2.4.18 (debian/woody) | ||
| Private report: | No | CVE-ID: | None | ||
[2003-04-13 09:24 UTC] fukusaka at xa2 dot so-net dot ne dot jp
There is a leak of execution of free of LOGINREC and DBPROCESS
inside sybase_connet/sybase_pconnet of Sybase (dblib).
This leak occurs, only when it is a system at the high load time,
is that the number of connection of ASE exceeds several times from usual,
and causes the error with the scarce reproducibility of a sybase function.
A patch like this should work:
Index: php_sybase_db.c
===================================================================
RCS file: /repository/php4/ext/sybase/php_sybase_db.c,v
retrieving revision 1.38.2.5
diff -u -r1.38.2.5 php_sybase_db.c
--- php_sybase_db.c 31 Dec 2002 16:35:36 -0000 1.38.2.5
+++ php_sybase_db.c 13 Apr 2003 13:13:21 -0000
@@ -478,6 +478,7 @@
php_sybase_module.num_persistent++;
php_sybase_module.num_links++;
} else { /* we do */
+ dbloginfree(sybase.login);
if (Z_TYPE_P(le) != php_sybase_module.le_plink) {
php_error(E_WARNING,"Sybase: Hashed persistent link is not a Sybase link!");
efree(hashed_details);
@@ -487,7 +488,8 @@
sybase_ptr = (sybase_link *) le->ptr;
/* test that the link hasn't died */
if (DBDEAD(sybase_ptr->link)==TRUE) {
- if ((sybase_ptr->link=PHP_SYBASE_DBOPEN(sybase_ptr->login,host))==FAIL) {
+ dbclose(sybase_ptr->link);
+ if ((sybase_ptr->link=PHP_SYBASE_DBOPEN(sybase_ptr->login,host))==NULL) {
/*php_error(E_WARNING,"Sybase: Link to server lost, unable to reconnect");*/
zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_length+1);
efree(hashed_details);
@@ -514,6 +516,7 @@
int type,link;
void *ptr;
+ dbloginfree(sybase.login);
if (Z_TYPE_P(index_ptr) != le_index_ptr) {
efree(hashed_details);
RETURN_FALSE;
@@ -532,12 +535,14 @@
if (php_sybase_module.max_links!=-1 && php_sybase_module.num_links>=php_sybase_module.max_links) {
php_error(E_WARNING,"Sybase: Too many open links (%d)",php_sybase_module.num_links);
efree(hashed_details);
+ dbloginfree(sybase.login);
RETURN_FALSE;
}
if ((sybase.link=PHP_SYBASE_DBOPEN(sybase.login,host))==NULL) {
/*php_error(E_WARNING,"Sybase: Unable to connect to server: %s",sybase_error(sybase));*/
efree(hashed_details);
+ dbloginfree(sybase.login);
RETURN_FALSE;
}
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2003-04-14 20:00 UTC] iliaa@php.net