]> granicus.if.org Git - php/commitdiff
Corrected memory leak in read().
authorChris Vandomelen <chrisv@php.net>
Thu, 14 Sep 2000 21:48:15 +0000 (21:48 +0000)
committerChris Vandomelen <chrisv@php.net>
Thu, 14 Sep 2000 21:48:15 +0000 (21:48 +0000)
ext/sockets/sockets.c

index c1b473bb612fd1af5ad98a0935bad756bedb1b02..a193389e1cb001848ef568dd33b5894cb807aae7 100644 (file)
@@ -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);
        }
 }