From df0e2f0dc8f4fbd31faa6c207931adde4dbe2f0c Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 9 Feb 2008 16:28:15 +0100 Subject: [PATCH] The section handler is now stopped before the device is destroyed --- CONTRIBUTORS | 2 ++ HISTORY | 4 ++++ device.c | 23 +++++++++++++++++------ device.h | 9 +++++++-- dvbdevice.c | 3 ++- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 53a3cd13..4bd828b2 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -86,6 +86,7 @@ Deti Fliegl for implementing the 'CurrentChannel' setup parameter for fixing setting the OSD size in the 'Confirm' interface call for fixing handling improper buffer lengths in the EIT parser + for a patch that was used to implement StopSectionHandler() Dave Chapman for implementing support for the teletext PID @@ -1158,6 +1159,7 @@ Reinhard Nissl for a patch that was used to fix handling small PES packets that caused subtitles to be displayed late in live mode for a patch that was used to implement handling of DVB-S2 + for reporting an invalid access in the section handler when ending VDR Richard Robson for reporting freezing replay if a timer starts while in Transfer Mode from the diff --git a/HISTORY b/HISTORY index 80b85eff..120fa890 100644 --- a/HISTORY +++ b/HISTORY @@ -5599,3 +5599,7 @@ Video Disk Recorder Revision History by Andreas Brugger). - Improved sending all frames to devices that can handle them in fast forward trick speeds, including subtitles (thanks to Timo Eskola). +- The section handler is now stopped before the device is destroyed, to avoid + accessing file handles after they have become invalid (thanks to Reinhard + Nissl for reporting an invalid access when ending VDR, and to Deti Fliegl for + a patch that was used to implement StopSectionHandler()). diff --git a/device.c b/device.c index 16b88a26..be9e7004 100644 --- a/device.c +++ b/device.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 1.151 2008/02/09 15:09:04 kls Exp $ + * $Id: device.c 1.152 2008/02/09 16:10:56 kls Exp $ */ #include "device.h" @@ -264,11 +264,6 @@ cDevice::~cDevice() DetachAllReceivers(); delete liveSubtitle; delete dvbSubtitleConverter; - delete nitFilter; - delete sdtFilter; - delete patFilter; - delete eitFilter; - delete sectionHandler; delete pesAssembler; } @@ -650,6 +645,22 @@ void cDevice::StartSectionHandler(void) } } +void cDevice::StopSectionHandler(void) +{ + if (sectionHandler) { + delete nitFilter; + delete sdtFilter; + delete patFilter; + delete eitFilter; + delete sectionHandler; + nitFilter = NULL; + sdtFilter = NULL; + patFilter = NULL; + eitFilter = NULL; + sectionHandler = NULL; + } +} + int cDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask) { return -1; diff --git a/device.h b/device.h index 34e6771e..48e31123 100644 --- a/device.h +++ b/device.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.h 1.88 2008/02/08 13:48:31 kls Exp $ + * $Id: device.h 1.89 2008/02/09 16:05:24 kls Exp $ */ #ifndef __DEVICE_H @@ -302,7 +302,12 @@ private: protected: void StartSectionHandler(void); ///< A derived device that provides section data must call - ///< this function to actually set up the section handler. + ///< this function (typically in its constructor) to actually set + ///< up the section handler. + void StopSectionHandler(void); + ///< A device that has called StartSectionHandler() must call this + ///< function (typically in its destructor) to stop the section + ///< handler. public: virtual int OpenFilter(u_short Pid, u_char Tid, u_char Mask); ///< Opens a file handle for the given filter data. diff --git a/dvbdevice.c b/dvbdevice.c index a39a4d24..c7408d35 100644 --- a/dvbdevice.c +++ b/dvbdevice.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.c 1.169 2008/02/08 13:48:31 kls Exp $ + * $Id: dvbdevice.c 1.170 2008/02/09 16:11:44 kls Exp $ */ #include "dvbdevice.h" @@ -433,6 +433,7 @@ cDvbDevice::cDvbDevice(int n) cDvbDevice::~cDvbDevice() { + StopSectionHandler(); delete spuDecoder; delete dvbTuner; delete ciAdapter;