Date: 09/14/00
- Next message: Robert Cummings: "[PHP-DEV] error_reporting qestion."
- Previous message: Andi Gutmans: "[PHP-DEV] doc_root problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
ID: 6747
Updated by: chrisv
Reported By: vincent.negrier <email protected>
Status: Closed
Bug Type: Sockets related
Assigned To:
Comments:
Fixed in CVS.
Previous Comments:
---------------------------------------------------------------------------
[2000-09-13 23:55:04] vincent.negrier <email protected>
My problem was the following :
Each call to read($socket, &$buffer, $length) on a non-blocking INET socket leaked $length bytes of memory.
I made a quick fix, it no longer leaks memory but I'm not sure i've done it the right way.
source code from the read() function in ext/sockets/sockets.c :
original:
tmpbuf = emalloc(Z_LVAL_PP(length)*sizeof(char));
if (tmpbuf == NULL) {
php_error(E_WARNING, "Couldn't allocate memory from %s()", get_active_fu
RETURN_FALSE;
}
ret = read(Z_LVAL_PP(fd), tmpbuf, Z_LVAL_PP(length));
if (ret >= 0) {
Z_STRVAL_PP(buf) = tmpbuf;
Z_STRLEN_PP(buf) = ret;
RETURN_LONG(ret);
} else {
RETURN_LONG(-errno);
}
Modified:
tmpbuf = emalloc(Z_LVAL_PP(length)*sizeof(char));
if (tmpbuf == NULL) {
php_error(E_WARNING, "Couldn't allocate memory from %s()", get_active_fu
RETURN_FALSE;
}
ret = read(Z_LVAL_PP(fd), tmpbuf, Z_LVAL_PP(length));
if (ret >= 0) {
Z_STRVAL_PP(buf) = estrndup(tmpbuf, strlen(tmpbuf));
Z_STRLEN_PP(buf) = ret;
efree(tmpbuf);
RETURN_LONG(ret);
} else {
efree(tmpbuf);
RETURN_LONG(-errno);
}
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=6747
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Robert Cummings: "[PHP-DEV] error_reporting qestion."
- Previous message: Andi Gutmans: "[PHP-DEV] doc_root problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

