Fix memory leak in NetString::ReadStringFromStream.

This commit is contained in:
Gunnar Beutner 2013-09-18 07:32:40 +02:00
parent 46659e7551
commit 2ed8f1aaa7
1 changed files with 3 additions and 1 deletions

View File

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