Ticket #10933: 0001-libmythtv-Prevent-a-SEGV-in-MpegRecorder-run-when-en.patch

File 0001-libmythtv-Prevent-a-SEGV-in-MpegRecorder-run-when-en.patch, 2.0 KB (added by Lawrence Rust <lvr@…>, 12 years ago)
  • mythtv/libs/libmythtv/mpegrecorder.cpp

    From edc629bc37bc3f79bc3e9aed4ea6e33c38cb7926 Mon Sep 17 00:00:00 2001
    From: Lawrence Rust <lvr@softsystem.co.uk>
    Date: Mon, 23 Jul 2012 19:30:06 +0200
    Subject: [PATCH] libmythtv: Prevent a SEGV in MpegRecorder::run when encoding is stopped
    
    If the current video source is a demo recorder and liveTV is exited
    then the BE aborts with a SEGV:
    
    Program terminated with signal 11, Segmentation fault.
    0  0xb67f4038 in MpegRecorder::run (this=0x8aa3b00) at mpegrecorder.cpp:1028
    1028	                FD_SET(readfd, &rdset);
    (gdb) bt
    0  0xb67f4038 in MpegRecorder::run (this=0x8aa3b00) at mpegrecorder.cpp:1028
    1  0xb5e186e0 in MThread::run (this=0x8a62060) at mthread.cpp:319
    2  0xb5e18d34 in MThreadInternal::run (this=0x88cd100) at mthread.cpp:79
    3  0xb3b772e0 in QThreadPrivate::start (arg=0x88cd100)
        at thread/qthread_unix.cpp:266
    4  0xb3af9e99 in start_thread (arg=0xa0f39b70) at pthread_create.c:304
    5  0xb39359ee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
    (gdb) print readfd
    $1 = -1
    
    This is the result of MpegRecorder::StopEncoding closing 'readfd' and
    setting it to -1.
    
    Signed-off-by: Lawrence Rust <lvr@softsystem.co.uk>
    ---
     mythtv/libs/libmythtv/mpegrecorder.cpp |    7 +++++--
     1 files changed, 5 insertions(+), 2 deletions(-)
    
    diff --git a/mythtv/libs/libmythtv/mpegrecorder.cpp b/mythtv/libs/libmythtv/mpegrecorder.cpp
    index 3460263..567980a 100644
    a b void MpegRecorder::run(void) 
    10251025                tv.tv_sec = 5;
    10261026                tv.tv_usec = 0;
    10271027                FD_ZERO(&rdset);
    1028                 FD_SET(readfd, &rdset);
     1028                int fd = readfd;
     1029                if (fd < 0)
     1030                    break;  // StopEncoding was called
     1031                FD_SET(fd, &rdset);
    10291032
    1030                 switch (select(readfd + 1, &rdset, NULL, NULL, &tv))
     1033                switch (select(fd + 1, &rdset, NULL, NULL, &tv))
    10311034                {
    10321035                    case -1:
    10331036                        if (errno == EINTR)