Ticket #11844: NegativeStartIndexGuard.patch.v0

File NegativeStartIndexGuard.patch.v0, 4.0 KB (added by Bill Meek <<keemllib@…>, 4 years ago)
Line 
1diff --git a/mythtv/programs/mythbackend/services/channel.cpp b/mythtv/programs/mythbackend/services/channel.cpp
2index e81f397..899762c 100644
3--- a/mythtv/programs/mythbackend/services/channel.cpp
4+++ b/mythtv/programs/mythbackend/services/channel.cpp
5@@ -68,7 +68,7 @@ DTC::ChannelInfoList* Channel::GetChannelInfoList( uint nSourceID,
6     DTC::ChannelInfoList *pChannelInfos = new DTC::ChannelInfoList();
7 
8     //uint nTotalAvailable = static_cast<uint>(chanList.size());
9-    nStartIndex   = min( nStartIndex, nTotalAvailable );
10+    nStartIndex   = (nStartIndex > 0) ? min( nStartIndex, nTotalAvailable ) : 0;
11     nCount        = (nCount > 0) ? min( nCount, nTotalAvailable ) : nTotalAvailable;
12     int nEndIndex = min((nStartIndex + nCount), nTotalAvailable );
13 
14@@ -462,7 +462,7 @@ DTC::VideoMultiplexList* Channel::GetVideoMultiplexList( uint nSourceID,
15 
16     DTC::VideoMultiplexList *pVideoMultiplexes = new DTC::VideoMultiplexList();
17 
18-    nStartIndex   = min( nStartIndex, muxCount );
19+    nStartIndex   = (nStartIndex > 0) ? min( nStartIndex, muxCount ) : 0;
20     nCount        = (nCount > 0) ? min( nCount, muxCount ) : muxCount;
21     int nEndIndex = min((nStartIndex + nCount), muxCount );
22 
23diff --git a/mythtv/programs/mythbackend/services/dvr.cpp b/mythtv/programs/mythbackend/services/dvr.cpp
24index e3a0058..0d8690e 100644
25--- a/mythtv/programs/mythbackend/services/dvr.cpp
26+++ b/mythtv/programs/mythbackend/services/dvr.cpp
27@@ -346,7 +346,7 @@ DTC::ProgramList* Dvr::GetExpiringList( int nStartIndex,
28 
29     DTC::ProgramList *pPrograms = new DTC::ProgramList();
30 
31-    nStartIndex   = min( nStartIndex, (int)infoList.size() );
32+    nStartIndex   = (nStartIndex > 0) ? min( nStartIndex, (int)infoList.size() ) : 0;
33     nCount        = (nCount > 0) ? min( nCount, (int)infoList.size() ) : infoList.size();
34     int nEndIndex = min((nStartIndex + nCount), (int)infoList.size() );
35 
36@@ -665,7 +665,7 @@ DTC::ProgramList* Dvr::GetUpcomingList( int  nStartIndex,
37 
38     DTC::ProgramList *pPrograms = new DTC::ProgramList();
39 
40-    nStartIndex   = min( nStartIndex, (int)recordingList.size() );
41+    nStartIndex   = (nStartIndex > 0) ? min( nStartIndex, (int)recordingList.size() ) : 0;
42     nCount        = (nCount > 0) ? min( nCount, (int)recordingList.size() ) : recordingList.size();
43     int nEndIndex = min((nStartIndex + nCount), (int)recordingList.size() );
44 
45@@ -729,7 +729,7 @@ DTC::ProgramList* Dvr::GetConflictList( int  nStartIndex,
46 
47     DTC::ProgramList *pPrograms = new DTC::ProgramList();
48 
49-    nStartIndex   = min( nStartIndex, (int)recordingList.size() );
50+    nStartIndex   = (nStartIndex > 0) ? min( nStartIndex, (int)recordingList.size() ) : 0;
51     nCount        = (nCount > 0) ? min( nCount, (int)recordingList.size() ) : recordingList.size();
52     int nEndIndex = min((nStartIndex + nCount), (int)recordingList.size() );
53 
54@@ -1126,7 +1126,7 @@ DTC::RecRuleList* Dvr::GetRecordScheduleList( int nStartIndex,
55 
56     DTC::RecRuleList *pRecRules = new DTC::RecRuleList();
57 
58-    nStartIndex   = min( nStartIndex, (int)recList.size() );
59+    nStartIndex   = (nStartIndex > 0) ? min( nStartIndex, (int)recList.size() ) : 0;
60     nCount        = (nCount > 0) ? min( nCount, (int)recList.size() ) : recList.size();
61     int nEndIndex = min((nStartIndex + nCount), (int)recList.size() );
62 
63diff --git a/mythtv/programs/mythbackend/services/video.cpp b/mythtv/programs/mythbackend/services/video.cpp
64index def3de5..977517e 100644
65--- a/mythtv/programs/mythbackend/services/video.cpp
66+++ b/mythtv/programs/mythbackend/services/video.cpp
67@@ -92,7 +92,7 @@ DTC::VideoMetadataInfoList* Video::GetVideoList( const QString &Folder,
68 
69     DTC::VideoMetadataInfoList *pVideoMetadataInfos = new DTC::VideoMetadataInfoList();
70 
71-    nStartIndex   = min( nStartIndex, (int)videos.size() );
72+    nStartIndex   = (nStartIndex > 0) ? min( nStartIndex, (int)videos.size() ) : 0;
73     nCount        = (nCount > 0) ? min( nCount, (int)videos.size() ) : videos.size();
74     int nEndIndex = min((nStartIndex + nCount), (int)videos.size() );
75