Permalink
Browse files

Don't leak nextRecording or nextRingBuffer.

If a recorder was deleted after SetNextRecording has been called it
would leak a RecordingInfo and a RingBuffer. The RecordingInfo is
no big deal but the RingBuffer is holding an open file descriptor
and the application will start to misbehave if after we leak just
a few hundred of those since select() will no longer function
correctly.
  • Loading branch information...
daniel-kristjansson committed Dec 7, 2012
1 parent d945642 commit c1c09f7dfd1216d1124232d61867d3801c6e4a85
Showing with 17 additions and 1 deletion.
  1. +17 −1 mythtv/libs/libmythtv/recorders/recorderbase.cpp
@@ -66,6 +66,16 @@ RecorderBase::~RecorderBase(void)
ringBuffer = NULL;
}
SetRecording(NULL);
if (nextRingBuffer)
{
delete nextRingBuffer;
nextRingBuffer = NULL;
}
if (nextRecording)
{
delete nextRecording;
nextRecording = NULL;
}
}
void RecorderBase::SetRingBuffer(RingBuffer *rbuf)
@@ -117,10 +127,16 @@ void RecorderBase::SetNextRecording(const RecordingInfo *ri, RingBuffer *rb)
// Then we set the next info
QMutexLocker locker(&nextRingBufferLock);
nextRecording = NULL;
if (nextRecording)
{
delete nextRecording;
nextRecording = NULL;
}
if (ri)
nextRecording = new RecordingInfo(*ri);
if (nextRingBuffer)
delete nextRingBuffer;
nextRingBuffer = rb;
}

0 comments on commit c1c09f7

Please sign in to comment.