From 3de4811a424e984a1dfa271a3be5f4137c935bc1 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 31 May 2009 10:02:20 +0200 Subject: Fixed a memory leak when reaching the end of a recording during replay --- dvbplayer.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'dvbplayer.c') diff --git a/dvbplayer.c b/dvbplayer.c index 219de497..ebd9eac6 100644 --- a/dvbplayer.c +++ b/dvbplayer.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbplayer.c 2.15 2009/04/19 15:19:10 kls Exp $ + * $Id: dvbplayer.c 2.16 2009/05/31 09:59:43 kls Exp $ */ #include "dvbplayer.h" @@ -461,9 +461,11 @@ void cDvbPlayer::Action(void) esyslog("ERROR: frame larger than buffer (%d > %d)", Length, MAXFRAMESIZE); Length = MAXFRAMESIZE; } - b = MALLOC(uchar, Length); + b = NULL; } - if (!eof) { + if (!eof && Length > 0) { + if (!b) + b = MALLOC(uchar, Length); int r = nonBlockingFileReader->Read(replayFile, b, Length); if (r > 0) { WaitingForData = false; @@ -475,13 +477,17 @@ void cDvbPlayer::Action(void) readFrame = new cFrame(b, -r, ftUnknown, readIndex, Pts); // hands over b to the ringBuffer b = NULL; } - else if (r == 0) - eof = true; else if (r < 0 && errno == EAGAIN) WaitingForData = true; - else if (r < 0 && FATALERRNO) { - LOG_ERROR; - break; + else { + free(b); + b = NULL; + if (r == 0) + eof = true; + else if (r < 0 && FATALERRNO) { + LOG_ERROR; + break; + } } } } -- cgit v1.2.3