Ticket #5140: libs_libmythtv_mpegrecorder.cpp-make-sure-device-file-desc-is-open.patch

File libs_libmythtv_mpegrecorder.cpp-make-sure-device-file-desc-is-open.patch, 925 bytes (added by Erik Hovland <erik@…>, 12 years ago)

check QFile::open()

  • libs/libmythtv/mpegrecorder.cpp

    The ivtv device open() call is not checked to see if it worked. If it
    
    From: Erik Hovland <erik@hovland.org>
    
    didn't we could be passing -1 to either close or read. Both
    bad ideas.
    ---
    
     libs/libmythtv/mpegrecorder.cpp |    8 ++++++++
     1 files changed, 8 insertions(+), 0 deletions(-)
    
    diff --git a/libs/libmythtv/mpegrecorder.cpp b/libs/libmythtv/mpegrecorder.cpp
    index 43675db..2746400 100644
    a b void MpegRecorder::StartRecording(void) 
    852852        if (readfd < 0)
    853853            readfd = open(videodevice.ascii(), O_RDWR);
    854854
     855        if (readfd == -1)
     856        {
     857            VERBOSE(VB_IMPORTANT,
     858                    LOC_ERR + QString("Open error on device %1")
     859                              .arg(videodevice.ascii()));
     860            continue;
     861        }
     862
    855863        tv.tv_sec = 5;
    856864        tv.tv_usec = 0;
    857865        FD_ZERO(&rdset);