Ticket #5125: libs_libmythtv_hdhrsignalmonitor.cpp-always_check-dyn_cast.patch

File libs_libmythtv_hdhrsignalmonitor.cpp-always_check-dyn_cast.patch, 1.1 KB (added by Erik Hovland <erik@…>, 12 years ago)

check dynamic_cast

  • libs/libmythtv/hdhrsignalmonitor.cpp

    dynamic_cast can return 0.
    
    From: Erik Hovland <erik@hovland.org>
    
    
    ---
    
     libs/libmythtv/hdhrsignalmonitor.cpp |    9 +++++++++
     1 files changed, 9 insertions(+), 0 deletions(-)
    
    diff --git a/libs/libmythtv/hdhrsignalmonitor.cpp b/libs/libmythtv/hdhrsignalmonitor.cpp
    index acdc594..4d691c1 100644
    a b bool HDHRSignalMonitor::UpdateFiltersFromStreamData(void) 
    115115            del_pids.push_back(fit.key());
    116116
    117117    HDHRChannel *hdhr = dynamic_cast<HDHRChannel*>(channel);
     118    if (!hdhr)
     119        return false;
     120
    118121    // Remove PIDs
    119122    bool ok = true;
    120123    vector<int>::iterator dit = del_pids.begin();
    void HDHRSignalMonitor::RunTableMonitor(void) 
    148151    }
    149152
    150153    HDHRChannel *hdrc = dynamic_cast<HDHRChannel*>(channel);
     154    if (!hdrc)
     155    {
     156        VERBOSE(VB_IMPORTANT, LOC_ERR + "Failed dynamic_cast of channel");
     157        return;
     158    }
     159
    151160    uint localPort = hdhomerun_video_get_local_port(_video_socket);
    152161    if (!hdrc->DeviceSetTarget(localPort))
    153162    {