Fixed a possible crash in pid scanner.

This commit is contained in:
Rolf Ahrenberg 2009-02-25 22:52:25 +02:00
parent ec2ec19f68
commit 73906ab698
2 changed files with 30 additions and 28 deletions

View File

@ -83,4 +83,4 @@ VDR Plugin 'iptv' Revision History
- Updated for vdr-1.7.4. - Updated for vdr-1.7.4.
- Fixed blacklisting of PAT section filter. - Fixed blacklisting of PAT section filter.
- Set max IPTV device count to VDR's max devices. - Set max IPTV device count to VDR's max devices.
- Fixed a possible crash in sid scanner. - Fixed a possible crash in sid and pid scanners.

View File

@ -120,36 +120,38 @@ void cPidScanner::Process(const uint8_t* buf)
return; return;
} }
cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID()); cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID());
int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated if (IptvChannel) {
int Dpids[MAXDPIDS + 1] = { 0 }; int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
int Spids[MAXSPIDS + 1] = { 0 }; int Dpids[MAXDPIDS + 1] = { 0 };
char ALangs[MAXAPIDS][MAXLANGCODE2] = { "" }; int Spids[MAXSPIDS + 1] = { 0 };
char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" }; char ALangs[MAXAPIDS][MAXLANGCODE2] = { "" };
char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" }; char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
int Ppid = IptvChannel->Ppid(); char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
int Tpid = IptvChannel->Tpid(); int Ppid = IptvChannel->Ppid();
bool foundApid = false; int Tpid = IptvChannel->Tpid();
if (numVpids < PIDSCANNER_VPID_COUNT) bool foundApid = false;
Vpid = 0; // No detected video pid if (numVpids < PIDSCANNER_VPID_COUNT)
else if (numApids < PIDSCANNER_APID_COUNT) Vpid = 0; // No detected video pid
Apid = 0; // No detected audio pid else if (numApids < PIDSCANNER_APID_COUNT)
for (unsigned int i = 1; i < MAXAPIDS; ++i) { Apid = 0; // No detected audio pid
Apids[i] = IptvChannel->Apid(i); for (unsigned int i = 1; i < MAXAPIDS; ++i) {
if (Apids[i] && (Apids[i] == Apid)) Apids[i] = IptvChannel->Apid(i);
foundApid = true; if (Apids[i] && (Apids[i] == Apid))
} foundApid = true;
if (!foundApid) }
Apids[0] = Apid; if (!foundApid)
for (unsigned int i = 0; i < MAXDPIDS; ++i) Apids[0] = Apid;
Dpids[i] = IptvChannel->Dpid(i); for (unsigned int i = 0; i < MAXDPIDS; ++i)
for (unsigned int i = 0; i < MAXSPIDS; ++i) Dpids[i] = IptvChannel->Dpid(i);
Spids[i] = IptvChannel->Spid(i); for (unsigned int i = 0; i < MAXSPIDS; ++i)
debug("cPidScanner::Process(): Vpid=0x%04X, Apid=0x%04X\n", Vpid, Apid); Spids[i] = IptvChannel->Spid(i);
debug("cPidScanner::Process(): Vpid=0x%04X, Apid=0x%04X\n", Vpid, Apid);
#if defined(APIVERSNUM) && APIVERSNUM >= 10700 #if defined(APIVERSNUM) && APIVERSNUM >= 10700
IptvChannel->SetPids(Vpid, Ppid, 0, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid); IptvChannel->SetPids(Vpid, Ppid, 0, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
#else #else
IptvChannel->SetPids(Vpid, Ppid, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid); IptvChannel->SetPids(Vpid, Ppid, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
#endif #endif
}
Channels.Unlock(); Channels.Unlock();
process = false; process = false;
} }