Ticket #5302: programs_mythfrontend_mythappearance.cpp-check-dyn_cast.patch

File programs_mythfrontend_mythappearance.cpp-check-dyn_cast.patch, 1.3 KB (added by Erik Hovland <erik@…>, 12 years ago)
  • programs/mythfrontend/mythappearance.cpp

    dyanmic_cast can return zero. It should be checked and reported.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     programs/mythfrontend/mythappearance.cpp |    7 ++++++-
     1 files changed, 6 insertions(+), 1 deletions(-)
    
    diff --git a/programs/mythfrontend/mythappearance.cpp b/programs/mythfrontend/mythappearance.cpp
    index a525723..c3322e7 100644
    a b bool MythAppearance::Create() 
    6464
    6565    m_topleftarrow = dynamic_cast<MythUIImage *> (GetChild("topleft"));
    6666    m_bottomrightarrow = dynamic_cast<MythUIImage *> (GetChild("bottomright"));
    67 
    6867    m_size = dynamic_cast<MythUIText *> (GetChild("size"));
    6968    m_offsets = dynamic_cast<MythUIText *> (GetChild("offsets"));
    7069    m_changeamount = dynamic_cast<MythUIText *> (GetChild("changeamount"));
    7170    m_offsets = dynamic_cast<MythUIText *> (GetChild("offsets"));
    7271    m_changeamount = dynamic_cast<MythUIText *> (GetChild("changeamount"));
     72    if (!m_topleftarrow || !m_bottomrightarrow || !m_size || !m_offsets ||
     73        !m_changeamount || !m_offsets || !m_changeamount)
     74    {
     75        VERBOSE(VB_IMPORTANT, "Unable to dynamically cast a child");
     76        return false;
     77    }
    7378
    7479    m_arrowsize_x = m_topleftarrow->GetArea().width();
    7580    m_arrowsize_y = m_topleftarrow->GetArea().height();