Ticket #5298: libs_libmythtv-check-return-defects.patch

File libs_libmythtv-check-return-defects.patch, 5.5 KB (added by Erik Hovland <erik@…>, 18 years ago)
  • libs/libmythtv/NuppelVideoRecorder.cpp

    Check the return value for null or check the pointer for null before
    
    From: Erik Hovland <erik@hovland.org>
    
    dereferencing.
    ---
    
     libs/libmythtv/NuppelVideoRecorder.cpp |    7 +++++++
     libs/libmythtv/avformatdecoder.cpp     |   19 +++++++++++--------
     libs/libmythtv/fifowriter.cpp          |    3 ++-
     libs/libmythtv/osdimagecache.cpp       |    8 +++++++-
     libs/libmythtv/viewschdiff.cpp         |    5 +++++
     libs/libmythtv/xine_demux_sputext.c    |    2 ++
     6 files changed, 34 insertions(+), 10 deletions(-)
    
    diff --git a/libs/libmythtv/NuppelVideoRecorder.cpp b/libs/libmythtv/NuppelVideoRecorder.cpp
    index d24e38a..b599847 100644
    a b void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync,  
    30813081            QMutexLocker locker(&avcodeclock);
    30823082            tmp = avcodec_encode_video(mpa_vidctx, (unsigned char *)strm,
    30833083                                       len, &mpa_picture);
     3084            if (tmp == -1)
     3085            {
     3086                VERBOSE(VB_IMPORTANT,
     3087                        LOC_ERR + "NuppelVideoRecorder::WriteVideo : "
     3088                                  "avcodec_encode_video() failed");
     3089                return;
     3090            }
    30843091        }
    30853092    }
    30863093    else
  • libs/libmythtv/avformatdecoder.cpp

    diff --git a/libs/libmythtv/avformatdecoder.cpp b/libs/libmythtv/avformatdecoder.cpp
    index 1315686..e7b4735 100644
    a b void AvFormatDecoder::ScanTeletextCaptions(int av_index)  
    13731373 */
    13741374void AvFormatDecoder::ScanDSMCCStreams(void)
    13751375{
    1376     if (!ic->cur_pmt_sect)
     1376    if (!ic || !ic->cur_pmt_sect)
    13771377        return;
    13781378
    13791379    if (!itv && ! (itv = GetNVP()->GetInteractiveTV()))
    bool AvFormatDecoder::GetFrame(int onlyvideo)  
    35413541                    if (!allowedquit && (onlyvideo < 0))
    35423542                    {
    35433543                        uint fill, total;
    3544                         GetNVP()->GetAudioBufferStatus(fill, total);
    3545                         total /= 6; // HACK needed for some audio files
    3546                         allowedquit =
    3547                             (fill == 0) || (fill > (total>>1)) ||
    3548                             ((total - fill) < (uint) data_size) ||
    3549                             (ofill + total_decoded_audio > (total>>2)) ||
    3550                             ((total - fill) < (uint) data_size * 2);
     3544                        if (GetNVP()->GetAudioBufferStatus(fill, total)) {
     3545                            total /= 6; // HACK needed for some audio files
     3546                            allowedquit =
     3547                                (fill == 0) || (fill > (total>>1)) ||
     3548                                ((total - fill) < (uint) data_size) ||
     3549                                (ofill + total_decoded_audio > (total>>2)) ||
     3550                                ((total - fill) < (uint) data_size * 2);
     3551                        } else
     3552                            VERBOSE(VB_IMPORTANT, LOC_ERR + "AvFormatDecoder::GetFrame : "
     3553                                    "Failed topping off buffers in audio only mode");
    35513554                    }
    35523555
    35533556                    break;
  • libs/libmythtv/fifowriter.cpp

    diff --git a/libs/libmythtv/fifowriter.cpp b/libs/libmythtv/fifowriter.cpp
    index 15addc2..38d0d42 100644
    a b void FIFOWriter::FIFOWriteThread(void)  
    142142            break;
    143143        if (fd == -1)
    144144            fd = open(filename[id].ascii(), O_WRONLY| O_SYNC);
    145         write(fd, fb_outptr[id]->data, fb_outptr[id]->blksize);
     145        if (fd >= 0)
     146            write(fd, fb_outptr[id]->data, fb_outptr[id]->blksize);
    146147        pthread_mutex_lock(&fifo_lock[id]);
    147148        fb_outptr[id] = fb_outptr[id]->next;
    148149        pthread_cond_signal(&full_cond[id]);
  • libs/libmythtv/osdimagecache.cpp

    diff --git a/libs/libmythtv/osdimagecache.cpp b/libs/libmythtv/osdimagecache.cpp
    index a3f986a..d5be817 100644
    a b OSDImageCacheValue *OSDImageCache::Get(const QString &key, bool useFile)  
    172172
    173173    QDir dir(MythContext::GetConfDir() + "/osdcache/");
    174174    QFile cacheFile(dir.path() + "/" + key);
    175     cacheFile.open(QIODevice::ReadOnly);
     175    if (!cacheFile.open(QIODevice::IO_ReadOnly))
     176    {
     177        VERBOSE(VB_IMPORTANT,
     178                LOC_ERR + key + " Failed opening read-only cache file");
     179        return NULL;
     180    }
     181
    176182    uint32_t imwidth  = 0;
    177183    uint32_t imheight = 0;
    178184
  • libs/libmythtv/viewschdiff.cpp

    diff --git a/libs/libmythtv/viewschdiff.cpp b/libs/libmythtv/viewschdiff.cpp
    index e618e66..c321299 100644
    a b void ViewScheduleDiff::updateBackground(void)  
    201201    QPainter tmp(&bground);
    202202
    203203    LayerSet *container = theme->GetSet("background");
     204    if (!container)
     205        return;
     206
    204207    container->Draw(&tmp, 0, 0);
    205208
    206209    tmp.end();
    void ViewScheduleDiff::edit()  
    263266void ViewScheduleDiff::upcoming()
    264267{
    265268    ProgramInfo *pi = CurrentProgram();
     269    if (!pi)
     270        return;
    266271
    267272    ProgLister *pl = new ProgLister(plTitle, pi->title, "",
    268273                                   gContext->GetMainWindow(), "proglist");
  • libs/libmythtv/xine_demux_sputext.c

    diff --git a/libs/libmythtv/xine_demux_sputext.c b/libs/libmythtv/xine_demux_sputext.c
    index b4bdb23..5ca78fc 100644
    a b static subtitle_t *sub_read_line_ssa(demux_sputext_t *this,subtitle_t *current)  
    523523                   line3) < 9       );
    524524 
    525525  line2=strchr(line3, ',');
     526  if (!line2)
     527    return NULL;
    526528 
    527529  for (comma = 4; comma < max_comma; comma ++)
    528530    {