From: Chris Vandomelen Date: Thu, 14 Sep 2000 21:48:15 +0000 (+0000) Subject: Corrected memory leak in read(). X-Git-Tag: php-4.0.3RC1~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d3ca6394ebda0cd60fabd14481f56f4e395cb8c4;p=php Corrected memory leak in read(). --- diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index c1b473bb61..a193389e1c 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -602,11 +602,14 @@ PHP_FUNCTION(read) ret = read(Z_LVAL_PP(fd), tmpbuf, Z_LVAL_PP(length)); if (ret >= 0) { - Z_STRVAL_PP(buf) = tmpbuf; + Z_STRVAL_PP(buf) = estrndup(tmpbuf,strlen(tmpbuf)); Z_STRLEN_PP(buf) = ret; + efree(tmpbuf); + RETURN_LONG(ret); } else { + efree(tmpbuf); RETURN_LONG(-errno); } }