mirror of https://github.com/Icinga/icinga2.git
Fix memory leak in the StdioStream class.
This commit is contained in:
parent
fe4fd67405
commit
d86767e8e3
|
@ -34,6 +34,11 @@ StdioStream::StdioStream(std::iostream *innerStream, bool ownsStream)
|
|||
: m_InnerStream(innerStream), m_OwnsStream(ownsStream)
|
||||
{ }
|
||||
|
||||
StdioStream::~StdioStream(void)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
size_t StdioStream::Read(void *buffer, size_t size)
|
||||
{
|
||||
ObjectLock olock(this);
|
||||
|
@ -51,6 +56,8 @@ void StdioStream::Write(const void *buffer, size_t size)
|
|||
|
||||
void StdioStream::Close(void)
|
||||
{
|
||||
if (m_OwnsStream)
|
||||
if (m_OwnsStream) {
|
||||
delete m_InnerStream;
|
||||
m_OwnsStream = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
typedef weak_ptr<StdioStream> WeakPtr;
|
||||
|
||||
StdioStream(std::iostream *innerStream, bool ownsStream);
|
||||
~StdioStream(void);
|
||||
|
||||
virtual size_t Read(void *buffer, size_t size);
|
||||
virtual void Write(const void *buffer, size_t size);
|
||||
|
|
Loading…
Reference in New Issue