|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: fukusaka at xa2 dot so-net dot ne dot jp
New email:
PHP Version: OS:


 [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
diff -u -r1.38.2.5 php_sybase_db.c
--- php_sybase_db.c	31 Dec 2002 16:35:36 -0000
+++ php_sybase_db.c	13 Apr 2003 13:13:21 -0000
@@ -478,6 +478,7 @@
 		} 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!");
@@ -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);
@@ -514,6 +516,7 @@
 			int type,link;
 			void *ptr;
+			dbloginfree(sybase.login);
 			if (Z_TYPE_P(index_ptr) != le_index_ptr) {
@@ -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);
+			dbloginfree(sybase.login);
 		if ((,host))==NULL) {
 			/*php_error(E_WARNING,"Sybase:  Unable to connect to server:  %s",sybase_error(sybase));*/
+			dbloginfree(sybase.login);


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-14 20:00 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Sep 26 11:03:37 2021 UTC