From d3ca6394ebda0cd60fabd14481f56f4e395cb8c4 Mon Sep 17 00:00:00 2001 From: Chris Vandomelen Date: Thu, 14 Sep 2000 21:48:15 +0000 Subject: [PATCH] Corrected memory leak in read(). --- ext/sockets/sockets.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); } } -- 2.50.1