From 2ed8f1aaa74351b7225080e3dc8b7add5ac5aa1d Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 18 Sep 2013 07:32:40 +0200 Subject: [PATCH] Fix memory leak in NetString::ReadStringFromStream. --- lib/base/netstring.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/base/netstring.cpp b/lib/base/netstring.cpp index be56a58fc..d4e171d0b 100644 --- a/lib/base/netstring.cpp +++ b/lib/base/netstring.cpp @@ -49,8 +49,10 @@ bool NetString::ReadStringFromStream(const Stream::Ptr& stream, String *str) int rc = stream->Read(header + read_length, 1); if (rc == 0) { - if (read_length == 0) + if (read_length == 0) { + free(header); return false; + } BOOST_THROW_EXCEPTION(std::runtime_error("Read() failed.")); }