Ticket #5147: programs_mythfrontend-make-sure-check-for-null-is-done-ticket-5147.patch

File programs_mythfrontend-make-sure-check-for-null-is-done-ticket-5147.patch, 2.8 KB (added by Erik Hovland <erik@…>, 12 years ago)

Latest version of the mythfrontend null checking patch

  • programs/mythfrontend/playbackbox.cpp

    Making sure that list is valid before dereferencing it. Forgetting to can
    
    From: Erik Hovland <erik@hovland.org>
    
    mean a segfault for mythfrontend
    ---
    
     programs/mythfrontend/playbackbox.cpp        |   32 +++++---------------------
     programs/mythfrontend/programrecpriority.cpp |   12 +++++-----
     2 files changed, 12 insertions(+), 32 deletions(-)
    
    diff --git a/programs/mythfrontend/playbackbox.cpp b/programs/mythfrontend/playbackbox.cpp
    index 4976f4f..38dd4df 100644
    a b void PlaybackBox::updateBackground(void) 
    679679    QPainter tmp(&bground);
    680680
    681681    LayerSet *container = theme->GetSet("background");
    682     if (container && type != Delete)
    683         container->Draw(&tmp, 0, 0);
    684     else
    685         container->Draw(&tmp, 0, 1);
     682    if (container)
     683        container->Draw(&tmp, 0, type == Delete);
    686684
    687685    tmp.end();
    688686    paintBackgroundPixmap = bground;
    void PlaybackBox::updateShowTitles(QPainter *p) 
    15381536        lcddev->switchToMenu(&lcdItems, lcdTitle);
    15391537
    15401538    // DRAW LAYERS
    1541     if (container && type != Delete)
    1542     {
    1543         container->Draw(&tmp, 0, 0);
    1544         container->Draw(&tmp, 1, 0);
    1545         container->Draw(&tmp, 2, 0);
    1546         container->Draw(&tmp, 3, 0);
    1547         container->Draw(&tmp, 4, 0);
    1548         container->Draw(&tmp, 5, 0);
    1549         container->Draw(&tmp, 6, 0);
    1550         container->Draw(&tmp, 7, 0);
    1551         container->Draw(&tmp, 8, 0);
    1552     }
    1553     else
     1539    if (container)
    15541540    {
    1555         container->Draw(&tmp, 0, 1);
    1556         container->Draw(&tmp, 1, 1);
    1557         container->Draw(&tmp, 2, 1);
    1558         container->Draw(&tmp, 3, 1);
    1559         container->Draw(&tmp, 4, 1);
    1560         container->Draw(&tmp, 5, 1);
    1561         container->Draw(&tmp, 6, 1);
    1562         container->Draw(&tmp, 7, 1);
    1563         container->Draw(&tmp, 8, 1);
     1541        bool typeIsEqToDel = type == Delete;
     1542        for (int i = 0; i < 9; i++)
     1543            container->Draw(&tmp, i, typeIsEqToDel);
    15641544    }
    15651545
    15661546    leftRight = false;
  • programs/mythfrontend/programrecpriority.cpp

    diff --git a/programs/mythfrontend/programrecpriority.cpp b/programs/mythfrontend/programrecpriority.cpp
    index 38c2c15..f92ee0f 100644
    a b void ProgramRecPriority::updateList(QPainter *p) 
    14301430                else
    14311431                    pageDowner = true;
    14321432            }
    1433         }
    14341433
    1435         ltype->SetDownArrow(pageDowner);
    1436         if (inData > 0)
    1437             ltype->SetUpArrow(true);
    1438         else
    1439             ltype->SetUpArrow(false);
     1434            ltype->SetDownArrow(pageDowner);
     1435            if (inData > 0)
     1436                ltype->SetUpArrow(true);
     1437            else
     1438                ltype->SetUpArrow(false);
     1439        }
    14401440    }
    14411441
    14421442    if (programData.count() <= 0)