From 0716d467b0cfc0eafafbb9d8258f86fcf22222bd Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Wed, 11 Nov 2009 18:23:41 +0100 Subject: some safety checks in mail announcements --- mail.c | 3 ++- noannounce.c | 13 ++++++++----- noannounce.h | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mail.c b/mail.c index 90c93ed..9ec7300 100644 --- a/mail.c +++ b/mail.c @@ -488,7 +488,8 @@ void cMailUpdateNotifier::SendUpdateNotifications() for (itae = announceEvents.begin(); itae != announceEvents.end(); itae++) { cNoAnnounce* noAnnounce = new cNoAnnounce(itae->GetEvent()); - NoAnnounces.Add(noAnnounce); + if (noAnnounce && noAnnounce->Valid()) + NoAnnounces.Add(noAnnounce); } if (announceEvents.size() > 0) { diff --git a/noannounce.c b/noannounce.c index 6ce8ed2..3c81066 100644 --- a/noannounce.c +++ b/noannounce.c @@ -42,11 +42,14 @@ cNoAnnounce::cNoAnnounce(const cEvent* e, time_t NextAnnounce) title = shortText = ""; startTime = 0; buffer = NULL; - if (e->Title()) title = e->Title(); - if (e->ShortText()) shortText = e->ShortText(); - channelID = e->ChannelID(); - startTime = e->StartTime(); - nextAnnounce = NextAnnounce; + if (e) + { + if (e->Title()) title = e->Title(); + if (e->ShortText()) shortText = e->ShortText(); + channelID = e->ChannelID(); + startTime = e->StartTime(); + nextAnnounce = NextAnnounce; + } } cNoAnnounce::~cNoAnnounce(void) diff --git a/noannounce.h b/noannounce.h index e497b03..c13aeac 100644 --- a/noannounce.h +++ b/noannounce.h @@ -50,6 +50,7 @@ public: bool Parse(const char *s); const char *ToText(void) const; bool Save(FILE *f); + bool Valid() { return startTime > 0; } }; class cNoAnnounces : public cConfig { -- cgit v1.2.3