diff --git a/CONTRIBUTORS b/CONTRIBUTORS index edb2c43a..ed4a4904 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3417,6 +3417,7 @@ Jasmin Jessich assigned to any devices for writing the ddci2 plugin and for valuable input and help with testing and debugging MTD support + for fixing selecting delivery system names in case of undefined indexes Martin Schirrmacher for suggesting to provide a way for skin plugins to get informed about the currently diff --git a/HISTORY b/HISTORY index 983f6714..7a59e087 100644 --- a/HISTORY +++ b/HISTORY @@ -9015,3 +9015,5 @@ Video Disk Recorder Revision History - Changed the default return value of cEpgHandler::BeginSegmentTransfer() to true, to avoid problems with derived classes that don't implement this function (reported by Frank Neumann). +- Fixed selecting delivery system names in case of undefined indexes (thanks to Jasmin + Jessich). diff --git a/dvbdevice.c b/dvbdevice.c index 70a4809b..d293914b 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 4.10 2017/05/01 12:48:55 kls Exp $ + * $Id: dvbdevice.c 4.11 2017/05/09 09:42:40 kls Exp $ */ #include "dvbdevice.h" @@ -1299,6 +1299,15 @@ const char *DeliverySystemNames[] = { NULL }; +static const int DeliverySystemNamesMax = sizeof(DeliverySystemNames) / sizeof(DeliverySystemNames[0]) - 2; // -1 to get the maximum allowed index & -1 for the NULL => -2 + +static const char *GetDeliverySystemName(int Index) +{ + if (Index > DeliverySystemNamesMax) + Index = 0; + return DeliverySystemNames[Index]; +}; + cDvbDevice::cDvbDevice(int Adapter, int Frontend) { adapter = Adapter; @@ -1396,9 +1405,9 @@ cString cDvbDevice::DeviceType(void) const { if (dvbTuner) { if (dvbTuner->FrontendType() != SYS_UNDEFINED) - return DeliverySystemNames[dvbTuner->FrontendType()]; + return GetDeliverySystemName(dvbTuner->FrontendType()); if (numDeliverySystems) - return DeliverySystemNames[deliverySystems[0]]; // to have some reasonable default + return GetDeliverySystemName(deliverySystems[0]); // to have some reasonable default } return ""; } @@ -1529,7 +1538,7 @@ bool cDvbDevice::QueryDeliverySystems(int fd_frontend) if (numDeliverySystems > 0) { cString ds(""); for (int i = 0; i < numDeliverySystems; i++) - ds = cString::sprintf("%s%s%s", *ds, i ? "," : "", DeliverySystemNames[deliverySystems[i]]); + ds = cString::sprintf("%s%s%s", *ds, i ? "," : "", GetDeliverySystemName(deliverySystems[i])); cString ms(""); if (frontendInfo.caps & FE_CAN_QPSK) { numModulations++; ms = cString::sprintf("%s%s%s", *ms, **ms ? "," : "", MapToUserString(QPSK, ModulationValues)); } if (frontendInfo.caps & FE_CAN_QAM_16) { numModulations++; ms = cString::sprintf("%s%s%s", *ms, **ms ? "," : "", MapToUserString(QAM_16, ModulationValues)); }