Skip to content

Commit

Permalink
Don't leak nextRecording or nextRingBuffer.
Browse files Browse the repository at this point in the history
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 c1c09f7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion mythtv/libs/libmythtv/recorders/recorderbase.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit c1c09f7

Please sign in to comment.