[mythtv-commits] Ticket #13531: Fix for Coverity 1456162 and 1456180

MythTV noreply at mythtv.org
Wed Dec 4 02:39:45 UTC 2019


#13531: Fix for Coverity 1456162 and 1456180
----------------------------------+--------------------------
     Reporter:  Gary Buhrmaster   |      Owner:  (none)
         Type:  Patch - Bug Fix   |     Status:  new
     Priority:  minor             |  Milestone:  needs_triage
    Component:  MythTV - General  |    Version:  Master Head
     Severity:  medium            |   Keywords:
Ticket locked:  0                 |
----------------------------------+--------------------------
 Low hanging fruit from Coverity scan.

 Sizeof returns size of the array (24 for a 3 array double on some
 architectures) and not the number of elements.

 Compile tested only.


 {{{
 diff --git a/mythtv/libs/libmythui/DisplayResScreen.cpp
 b/mythtv/libs/libmythui/DisplayResScreen.cpp
 index 44ffc8c015..a94fd319c5 100644
 --- a/mythtv/libs/libmythui/DisplayResScreen.cpp
 +++ b/mythtv/libs/libmythui/DisplayResScreen.cpp
 @@ -140,7 +140,7 @@ int DisplayResScreen::FindBestMatch(const
 DisplayResVector& dsr,
                  while (!end)
                  {
                      double precisions1[] = {0.001, 0.01, 0.1};
 -                    for (uint p = 0; p < sizeof(precisions1); p++)
 +                    for (uint p = 0; p <
 (sizeof(precisions1)/sizeof(precisions1[0])); p++)
                      {
                          double precision = precisions1[p];
                          for (size_t j=0; j < rates.size(); ++j)
 @@ -159,7 +159,7 @@ int DisplayResScreen::FindBestMatch(const
 DisplayResVector& dsr,
                      // Can't find exact frame rate, so try rounding to
 the
                      // nearest integer, so 23.97Hz will work with 24Hz
 etc
                      double precisions2[] = {0.01, 0.1, 1};
 -                    for (uint p = 0; p < sizeof(precisions2); p++)
 +                    for (uint p = 0; p <
 (sizeof(precisions2)/sizeof(precisions2[0])); p++)
                      {
                          double precision = precisions2[p];
                          double rounded = round(videorate);
 }}}

-- 
Ticket URL: <https://code.mythtv.org/trac/ticket/13531>
MythTV <http://www.mythtv.org>
MythTV Media Center


More information about the mythtv-commits mailing list