From 535cea507f1320ab82af0c493531127178e17726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Haso=C5=88?= Date: Thu, 2 Aug 2012 13:21:20 +0200 Subject: [PATCH] Avoid memory leak in SocketHandler (substr function in the first iteration) --- src/Monolog/Handler/SocketHandler.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Monolog/Handler/SocketHandler.php b/src/Monolog/Handler/SocketHandler.php index c9e857b2..1aaa22a5 100644 --- a/src/Monolog/Handler/SocketHandler.php +++ b/src/Monolog/Handler/SocketHandler.php @@ -257,7 +257,11 @@ class SocketHandler extends AbstractProcessingHandler $length = strlen($data); $sent = 0; while ($this->isConnected() && $sent < $length) { - $chunk = $this->fwrite(substr($data, $sent)); + if (0 == $sent) { + $chunk = $this->fwrite($data); + } else { + $chunk = $this->fwrite(substr($data, $sent)); + } if ($chunk === false) { throw new \RuntimeException("Could not write to socket"); }