summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasmin Jessich <jasmin@anw.at>2017-06-18 00:13:40 (GMT)
committerJasmin Jessich <jasmin@anw.at>2017-06-18 00:22:24 (GMT)
commit914fc339749a5d625bc0aa6367cb1c950df7702b (patch)
tree512268bdc60edf9d72cf6c48db089e4bfd00dbd7
parent18d3b23cf039ce1d1efb2898d4a8bd812a023f11 (diff)
downloadvdr-plugin-live-914fc339749a5d625bc0aa6367cb1c950df7702b.tar.gz
vdr-plugin-live-914fc339749a5d625bc0aa6367cb1c950df7702b.tar.bz2
Protect stored timers in SortedTimers list
- SortedTimers::GetByTimerId will now return "const cTimer *" to be sure the timer is never modified within live. Modifying or more worse deleting such a timer can lead to a segfault. This is no longer the case, but using const may protect future mistakes.
-rw-r--r--pages/edit_timer.ecpp2
-rw-r--r--pages/timers.ecpp2
-rw-r--r--timers.cpp8
-rw-r--r--timers.h10
4 files changed, 11 insertions, 11 deletions
diff --git a/pages/edit_timer.ecpp b/pages/edit_timer.ecpp
index 24bd022..a466ef6 100644
--- a/pages/edit_timer.ecpp
+++ b/pages/edit_timer.ecpp
@@ -48,7 +48,7 @@ string edit_timerreferer;
TimerConflictNotifier timerNotifier;
</%session>
<%request scope="page">
-cTimer* timer;
+const cTimer* timer;
</%request>
<%include>page_init.eh</%include>
<%cpp>
diff --git a/pages/timers.ecpp b/pages/timers.ecpp
index 91986dd..7b7bdc3 100644
--- a/pages/timers.ecpp
+++ b/pages/timers.ecpp
@@ -23,7 +23,7 @@ static const size_t maximumDescriptionLength = 300;
bool logged_in(false);
</%session>
<%request scope="page">
- cTimer* timer;
+ const cTimer* timer;
TimerConflictNotifier timerNotifier;
</%request>
<%include>page_init.eh</%include>
diff --git a/timers.cpp b/timers.cpp
index bb31ac8..d280a27 100644
--- a/timers.cpp
+++ b/timers.cpp
@@ -39,7 +39,7 @@ namespace vdrlive {
return builder.str();
}
- cTimer* SortedTimers::GetByTimerId( string const& timerid )
+ const cTimer* SortedTimers::GetByTimerId( string const& timerid )
{
vector< string > parts = StringSplit( timerid, ':' );
if ( parts.size() < 5 ) {
@@ -181,7 +181,7 @@ namespace vdrlive {
{
}
- void TimerManager::UpdateTimer( cTimer* timer, int flags, tChannelID& channel, string const& weekdays, string const& day,
+ void TimerManager::UpdateTimer( const cTimer* timer, int flags, tChannelID& channel, string const& weekdays, string const& day,
int start, int stop, int priority, int lifetime, string const& title, string const& aux )
{
cMutexLock lock( this );
@@ -220,7 +220,7 @@ namespace vdrlive {
throw HtmlError( error );
}
- void TimerManager::DelTimer( cTimer* timer )
+ void TimerManager::DelTimer( const cTimer* timer )
{
cMutexLock lock( this );
@@ -234,7 +234,7 @@ namespace vdrlive {
throw HtmlError( error );
}
- void TimerManager::ToggleTimerActive( cTimer* timer)
+ void TimerManager::ToggleTimerActive( const cTimer* timer)
{
cMutexLock lock( this );
diff --git a/timers.h b/timers.h
index 1fc86ff..30583f3 100644
--- a/timers.h
+++ b/timers.h
@@ -15,7 +15,7 @@ namespace vdrlive {
public:
static std::string GetTimerId(cTimer const& timer);
- cTimer* GetByTimerId(std::string const& timerid);
+ const cTimer* GetByTimerId(std::string const& timerid);
// en- or decodes a timer into an id usable for DOM Ids.
static std::string EncodeDomId(std::string const& timerid);
@@ -53,11 +53,11 @@ namespace vdrlive {
public:
SortedTimers& GetTimers() { return m_timers; }
- void UpdateTimer( cTimer* timer, int flags, tChannelID& channel, std::string const& weekdays, std::string const& day,
+ void UpdateTimer( const cTimer* timer, int flags, tChannelID& channel, std::string const& weekdays, std::string const& day,
int start, int stop, int priority, int lifetime, std::string const& title, std::string const& aux );
- void DelTimer( cTimer* timer);
- void ToggleTimerActive( cTimer* timer);
+ void DelTimer( const cTimer* timer);
+ void ToggleTimerActive( const cTimer* timer);
// may only be called from Plugin::MainThreadHook
void DoPendingWork();
void DoReloadTimers() { m_timers.ReloadTimers(); m_reloadTimers = false; }
@@ -65,7 +65,7 @@ namespace vdrlive {
void SetReloadTimers() { m_reloadTimers = true; }
private:
- typedef std::pair< cTimer*, std::string > TimerPair;
+ typedef std::pair< const cTimer*, std::string > TimerPair;
typedef std::pair< TimerPair, std::string > ErrorPair;
typedef std::list< TimerPair > TimerList;
typedef std::list< ErrorPair > ErrorList;