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.")); }