Ticket #5120: libs_libmythtv_firewiresignalmonitor.cpp-dyncast-can-be-null.patch

File libs_libmythtv_firewiresignalmonitor.cpp-dyncast-can-be-null.patch, 1.9 KB (added by Erik Hovland <erik@…>, 12 years ago)

check dynamic_cast

  • libs/libmythtv/firewiresignalmonitor.cpp

    dyncasts should be checked to see if they returned null.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmythtv/firewiresignalmonitor.cpp |   17 +++++++++++++++--
     1 files changed, 15 insertions(+), 2 deletions(-)
    
    diff --git a/libs/libmythtv/firewiresignalmonitor.cpp b/libs/libmythtv/firewiresignalmonitor.cpp
    index 529e251..d9c9a99 100644
    a b void FirewireSignalMonitor::HandlePAT(const ProgramAssociationTable *pat) 
    9595    AddFlags(kDTVSigMon_PATSeen);
    9696
    9797    FirewireChannel *fwchan = dynamic_cast<FirewireChannel*>(channel);
     98    if (!fwchan)
     99    {
     100        VERBOSE(VB_IMPORTANT, LOC_ERR + "HandlePAT() : "
     101                "dynamic_cast(channel) failed");
     102        return;
     103    }
     104
    98105    bool crc_bogus = !fwchan->GetFirewireDevice()->IsSTBBufferCleared();
    99106    if (crc_bogus && stb_needs_to_wait_for_pat &&
    100107        (stb_wait_for_pat_timer.elapsed() < (int)kBufferTimeout))
    void FirewireSignalMonitor::RunTableMonitor(void) 
    141148{
    142149    stb_needs_to_wait_for_pat = true;
    143150    stb_wait_for_pat_timer.start();
    144     dtvMonitorRunning = true;
    145151
    146152    VERBOSE(VB_CHANNEL, LOC + "RunTableMonitor(): -- begin");
    147153
    void FirewireSignalMonitor::RunTableMonitor(void) 
    151157        VERBOSE(VB_CHANNEL, LOC + "RunTableMonitor(): -- err end");
    152158        dtvMonitorRunning = false;
    153159        return;
    154     }
     160    } else
     161        dtvMonitorRunning = true;
    155162
    156163    FirewireDevice *dev = lchan->GetFirewireDevice();
    157164
    void FirewireSignalMonitor::UpdateValues(void) 
    214221    stb_needs_to_wait_for_power = false;
    215222
    216223    FirewireChannel *fwchan = dynamic_cast<FirewireChannel*>(channel);
     224    if (!fwchan)
     225    {
     226        VERBOSE(VB_IMPORTANT, LOC_ERR + "UpdateValues() : "
     227                "dynamic_cast(channel) failed");
     228        return;
     229    }
    217230
    218231    if (HasFlags(kFWSigMon_WaitForPower) && !HasFlags(kFWSigMon_PowerMatch))
    219232    {