Ticket #5547: mytharchive-defects.patch

File mytharchive-defects.patch, 7.9 KB (added by Erik Hovland <erik@…>, 16 years ago)

corrects any found defects in mytharchive

  • mythplugins/mytharchive/mytharchive/logviewer.cpp

    1. hbox is never used even though it is assigned. Removing the
       assignment allows some instructions to be saved.
    
    2. The call QFile::open() is not checked. in checkProcess. This should
       probably be done.
    
    3. size_bar might be null, should check before dereferencing.
    
    4. When vector::erase() is called on an interator the iterator is no
       longer valid according to tC++PL (Stroustrup). So decrementing the
       iterator is dangerous. Fortunately, erase() returns the next
       iterator. The patch assigns 'i' to that returned value so that the
       i-- is done on an always valid iterator.
    
    5. Using 65536 * 65536 is an overflow to QImage since int only goes to
       2^31. The solution in the MythTV tree was to use the Qt4 QImage ctor
       and the enum type. So that is what was done here.
    
    6. intID could potentially be used uninitialized.
    
    7. ifopalette() forgot to close the file handle. This technically is a
       file resource leak.
    
    8. yuvpallet and rgppalette could be used uninitialized in sup2dast.
    
    Signed-off-by: Erik Hovland <erik@hovland.org>
    
    ---
    
     mythplugins/mytharchive/mytharchive/logviewer.cpp  |    2 +-
     mythplugins/mytharchive/mytharchive/main.cpp       |   10 ++++++++--
     .../mytharchive/mytharchive/mythburnwizard.cpp     |   11 ++++++++---
     .../mytharchive/mytharchive/recordingselector.cpp  |    4 ++--
     .../mytharchive/mytharchive/thumbfinder.cpp        |    4 ++--
     mythplugins/mytharchive/mytharchivehelper/main.cpp |    6 +++---
     .../mytharchive/mytharchivehelper/pxsup2dast.c     |    4 ++++
     7 files changed, 28 insertions(+), 13 deletions(-)
    
    diff --git a/mythplugins/mytharchive/mytharchive/logviewer.cpp b/mythplugins/mytharchive/mytharchive/logviewer.cpp
    index eefcdf5..c09ec5c 100644
    a b LogViewer::LogViewer(MythMainWindow *parent, const char *name) 
    7777    hbox->addWidget(m_listbox);
    7878
    7979
    80     hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult));
     80    new Q3HBoxLayout(vbox, (int)(10 * wmult));
    8181
    8282    //  cancel Button
    8383    hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult));
  • mythplugins/mytharchive/mytharchive/main.cpp

    diff --git a/mythplugins/mytharchive/mytharchive/main.cpp b/mythplugins/mytharchive/mytharchive/main.cpp
    index 4ace977..e963ad9 100644
    a b bool checkProcess(const QString &lockFile) 
    5151    // read the PID from the lock file
    5252    QFile file(lockFile);
    5353   
    54     file.open(QIODevice::ReadOnly);
     54    bool bOK = file.open(QIODevice::ReadOnly);
     55
     56    if (!bOK)
     57    {
     58        VERBOSE(VB_GENERAL, QString("Unable to open file %1").arg(lockFile));
     59
     60        return true;
     61    }
    5562
    5663    QString line(file.readLine(100));
    5764
    58     bool bOK = false;
    5965    pid_t pid = line.toInt(&bOK);
    6066
    6167    if (!bOK)
  • mythplugins/mytharchive/mytharchive/mythburnwizard.cpp

    diff --git a/mythplugins/mytharchive/mytharchive/mythburnwizard.cpp b/mythplugins/mytharchive/mytharchive/mythburnwizard.cpp
    index 8479089..94067c5 100644
    a b void MythburnWizard::updateSizeBar(void) 
    279279    {
    280280        maxsize_text->show();
    281281        minsize_text->show();
    282         size_bar->show();
     282        if (size_bar)
     283            size_bar->show();
     284
    283285        currentsize_error_text->show();
    284286        currentsize_text->show();
    285287    }
    void MythburnWizard::updateSizeBar(void) 
    287289    {
    288290        maxsize_text->hide();
    289291        minsize_text->hide();
    290         size_bar->hide();
     292        if (size_bar)
     293            size_bar->hide();
     294
    291295        currentsize_error_text->hide();
    292296        currentsize_text->hide();
    293297    }
    void MythburnWizard::updateSizeBar(void) 
    336340            currentsize_text->show();
    337341    }
    338342
    339     size_bar->refresh();
     343    if (size_bar)
     344        size_bar->refresh();
    340345
    341346    if (show)
    342347        selectedChanged(selected_list->GetItemCurrent());
  • mythplugins/mytharchive/mytharchive/recordingselector.cpp

    diff --git a/mythplugins/mytharchive/mytharchive/recordingselector.cpp b/mythplugins/mytharchive/mytharchive/recordingselector.cpp
    index 58556c0..7730d03 100644
    a b void RecordingSelector::getRecordingList(void) 
    420420                VERBOSE(VB_IMPORTANT,
    421421                        QString("MythArchive cannot handle this file because it isn't available locally - %1")
    422422                                .arg(p->GetPlaybackURL(false, true)));
    423                 recordingList->erase(i);
     423                i = recordingList->erase(i);
    424424                i--;
    425425                continue;
    426426            }
    void RecordingSelector::getRecordingList(void) 
    428428            // ignore live tv and deleted recordings
    429429            if (p->recgroup == "LiveTV" || p->recgroup == "Deleted")
    430430            {
    431                 recordingList->erase(i);
     431                i = recordingList->erase(i);
    432432                i--;
    433433                continue;
    434434            }
  • mythplugins/mytharchive/mytharchive/thumbfinder.cpp

    diff --git a/mythplugins/mytharchive/mytharchive/thumbfinder.cpp b/mythplugins/mytharchive/mytharchive/thumbfinder.cpp
    index b0c6111..c9fccec 100644
    a b bool ThumbFinder::getFrameImage(bool needKeyFrame, int64_t requiredPTS) 
    847847        img_convert(&retbuf, PIX_FMT_RGBA32,
    848848                        (AVPicture*) m_frame, m_codecCtx->pix_fmt, m_frameWidth, m_frameHeight);
    849849
    850         QImage img(m_outputbuf, m_frameWidth, m_frameHeight, 32, NULL,
    851                     65536 * 65536, QImage::LittleEndian);
     850        QImage img(m_outputbuf, m_frameWidth, m_frameHeight,
     851                   QImage::Format_RGB32);
    852852
    853853        if (!img.save(m_frameFile.ascii(), "JPEG"))
    854854        {
  • mythplugins/mytharchive/mytharchivehelper/main.cpp

    diff --git a/mythplugins/mytharchive/mytharchivehelper/main.cpp b/mythplugins/mytharchive/mytharchivehelper/main.cpp
    index 6885186..3b8b499 100644
    a b int NativeArchive::exportVideo(QDomElement &itemNode, const QString &saveDirecto 
    752752    QString title = "", filename = "";
    753753    bool doDelete = false;
    754754    QString dbVersion = gContext->GetSetting("DBSchemaVer", "");
    755     int intID, categoryID = 0;
     755    int intID = 0, categoryID = 0;
    756756    QString coverFile = "";
    757757
    758758    title = itemNode.attribute("title");
    int grabThumbnail(QString inFile, QString thumbList, QString outFile, int frameC 
    18421842                        img_convert(&retbuf, PIX_FMT_RGBA32,
    18431843                                    (AVPicture*) frame, codecCtx->pix_fmt, width, height);
    18441844
    1845                         QImage img(outputbuf, width, height, 32, NULL,
    1846                                 65536 * 65536, QImage::LittleEndian);
     1845                        QImage img(outputbuf, width, height,
     1846                                   QImage::Format_RGB32);
    18471847
    18481848                        if (!img.save(filename.ascii(), saveFormat))
    18491849                        {
  • mythplugins/mytharchive/mytharchivehelper/pxsup2dast.c

    diff --git a/mythplugins/mytharchive/mytharchivehelper/pxsup2dast.c b/mythplugins/mytharchive/mytharchivehelper/pxsup2dast.c
    index 5b923fb..d17eae8 100644
    a b static void ifopalette(const char * filename, 
    367367    /* seek to palette */
    368368    xfseek0(fh, pgc + 0xa4);
    369369    xxfread(fh, buf, 16 * 4);
     370    fclose(fh);
    370371    for (i = 0; i < 16; i++)
    371372    {
    372373        eu8 * p = buf + i * 4 + 1;
    int sup2dast(const char *supfile, const char *ifofile ,int delay_ms) 
    863864        bool createpics;
    864865        FILE * fh;
    865866
     867        memset(yuvpalette, 0, sizeof(yuvpalette));
     868        memset(rgbpalette, 0, sizeof(rgbpalette));
     869
    866870        write(1, "\n", 1);
    867871        if (sizeof (char) != 1 || sizeof (int) < 2) /* very unlikely */
    868872            exc_throw(MiscError, "Incompatible variable sizes.");