Fixed a memory leak when reaching the end of a recording during replay

This commit is contained in:
Klaus Schmidinger 2009-05-31 10:02:20 +02:00
parent ea5ee20db1
commit 3de4811a42
3 changed files with 17 additions and 8 deletions

View File

@ -1217,6 +1217,7 @@ Reinhard Nissl <rnissl@gmx.de>
cDvbPlayer::Action()
for reporting a typo in aspect ratio 2.21:1
for reporting a problem in case the PIDs change during recording
for reporting a memory leak when reaching the end of a recording during replay
Richard Robson <richard_robson@beeb.net>
for reporting freezing replay if a timer starts while in Transfer Mode from the

View File

@ -6112,3 +6112,5 @@ Video Disk Recorder Revision History
- Fixed generating PAT/PMT version numbers in case the PIDs change during
recording (reported by Reinhard Nissl).
- Updated the Ukrainian OSD texts (thanks to Yarema Aka Knedlyk).
- Fixed a memory leak when reaching the end of a recording during replay (reported
by Reinhard Nissl).

View File

@ -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;
}
}
}
}