From a9d82331e63353e92a3673670de9007a9c93dc39 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 26 Nov 2017 15:02:54 +0100 Subject: [PATCH] Fixed a possible crash with plugins that retrieve player information after a replay has been stopped, but before the replay control has been destroyed --- CONTRIBUTORS | 2 ++ HISTORY | 6 +++++- dvbplayer.c | 3 ++- player.h | 10 +++++----- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 6ea191ea..7698d7b5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2840,6 +2840,8 @@ Johann Friedrichs for fixing handling VPS events outside the LingerLimit, which could cause recordings to stop prematurely for fixing handling timers during the change from DST to winter time + for fixing a possible crash with plugins that retrieve player information after a + replay has been stopped, but before the replay control has been destroyed Timo Helkio for reporting a hangup when replaying a TS recording with subtitles activated diff --git a/HISTORY b/HISTORY index 8b793f05..dbaa40e3 100644 --- a/HISTORY +++ b/HISTORY @@ -9162,7 +9162,7 @@ Video Disk Recorder Revision History a subdirectory. - SVDRP peering can now be limited to the default SVDRP host (see MANUAL for details). -2017-11-12: Version 2.3.9 +2017-11-26: Version 2.3.9 - Updated the Italian OSD texts (thanks to Diego Pierotto). - Updated the Finnish OSD texts (thanks to Rolf Ahrenberg). @@ -9201,3 +9201,7 @@ Video Disk Recorder Revision History - Added some comments regarding font height (thanks to Thomas Reufer). - Fixed handling timers during the change from DST to winter time (thanks to Johann Friedrichs). +- Added missing checks of 'player' in member functions of cControl, and setting + cControl::player to NULL in cDvbPlayerControl::Stop() to avoid a possible crash + with plugins that retrieve player information after a replay has been stopped, but + before the replay control has been destroyed (thanks to Johann Friedrich). diff --git a/dvbplayer.c b/dvbplayer.c index ca007353..d1c02f9f 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 4.4 2016/12/22 11:34:31 kls Exp $ + * $Id: dvbplayer.c 4.5 2017/11/26 14:55:03 kls Exp $ */ #include "dvbplayer.h" @@ -1003,6 +1003,7 @@ bool cDvbPlayerControl::Active(void) void cDvbPlayerControl::Stop(void) { + cControl::player = NULL; delete player; player = NULL; } diff --git a/player.h b/player.h index aeb8af8f..01b5f5c9 100644 --- a/player.h +++ b/player.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: player.h 4.2 2016/12/22 10:38:11 kls Exp $ + * $Id: player.h 4.3 2017/11/26 14:29:12 kls Exp $ */ #ifndef __PLAYER_H @@ -102,10 +102,10 @@ public: ///< skins as a last resort, in case they want to display the state of the ///< current player. The return value is expected to be a short, single line ///< string. The default implementation returns an empty string. - double FramesPerSecond(void) const { return player->FramesPerSecond(); } - bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) const { return player->GetIndex(Current, Total, SnapToIFrame); } - bool GetFrameNumber(int &Current, int &Total) const { return player->GetFrameNumber(Current, Total); } - bool GetReplayMode(bool &Play, bool &Forward, int &Speed) const { return player->GetReplayMode(Play, Forward, Speed); } + double FramesPerSecond(void) const { return player ? player->FramesPerSecond() : DEFAULTFRAMESPERSECOND; } + bool GetIndex(int &Current, int &Total, bool SnapToIFrame = false) const { return player ? player->GetIndex(Current, Total, SnapToIFrame) : false; } + bool GetFrameNumber(int &Current, int &Total) const { return player ? player->GetFrameNumber(Current, Total) : false; } + bool GetReplayMode(bool &Play, bool &Forward, int &Speed) const { return player ? player->GetReplayMode(Play, Forward, Speed) : false; } static void Launch(cControl *Control); static void Attach(void); static void Shutdown(void);