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) |
77 | 77 | hbox->addWidget(m_listbox); |
78 | 78 | |
79 | 79 | |
80 | | hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult)); |
| 80 | new Q3HBoxLayout(vbox, (int)(10 * wmult)); |
81 | 81 | |
82 | 82 | // cancel Button |
83 | 83 | hbox = new Q3HBoxLayout(vbox, (int)(10 * wmult)); |
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) |
51 | 51 | // read the PID from the lock file |
52 | 52 | QFile file(lockFile); |
53 | 53 | |
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 | } |
55 | 62 | |
56 | 63 | QString line(file.readLine(100)); |
57 | 64 | |
58 | | bool bOK = false; |
59 | 65 | pid_t pid = line.toInt(&bOK); |
60 | 66 | |
61 | 67 | if (!bOK) |
diff --git a/mythplugins/mytharchive/mytharchive/mythburnwizard.cpp b/mythplugins/mytharchive/mytharchive/mythburnwizard.cpp
index 8479089..94067c5 100644
a
|
b
|
void MythburnWizard::updateSizeBar(void) |
279 | 279 | { |
280 | 280 | maxsize_text->show(); |
281 | 281 | minsize_text->show(); |
282 | | size_bar->show(); |
| 282 | if (size_bar) |
| 283 | size_bar->show(); |
| 284 | |
283 | 285 | currentsize_error_text->show(); |
284 | 286 | currentsize_text->show(); |
285 | 287 | } |
… |
… |
void MythburnWizard::updateSizeBar(void) |
287 | 289 | { |
288 | 290 | maxsize_text->hide(); |
289 | 291 | minsize_text->hide(); |
290 | | size_bar->hide(); |
| 292 | if (size_bar) |
| 293 | size_bar->hide(); |
| 294 | |
291 | 295 | currentsize_error_text->hide(); |
292 | 296 | currentsize_text->hide(); |
293 | 297 | } |
… |
… |
void MythburnWizard::updateSizeBar(void) |
336 | 340 | currentsize_text->show(); |
337 | 341 | } |
338 | 342 | |
339 | | size_bar->refresh(); |
| 343 | if (size_bar) |
| 344 | size_bar->refresh(); |
340 | 345 | |
341 | 346 | if (show) |
342 | 347 | selectedChanged(selected_list->GetItemCurrent()); |
diff --git a/mythplugins/mytharchive/mytharchive/recordingselector.cpp b/mythplugins/mytharchive/mytharchive/recordingselector.cpp
index 58556c0..7730d03 100644
a
|
b
|
void RecordingSelector::getRecordingList(void) |
420 | 420 | VERBOSE(VB_IMPORTANT, |
421 | 421 | QString("MythArchive cannot handle this file because it isn't available locally - %1") |
422 | 422 | .arg(p->GetPlaybackURL(false, true))); |
423 | | recordingList->erase(i); |
| 423 | i = recordingList->erase(i); |
424 | 424 | i--; |
425 | 425 | continue; |
426 | 426 | } |
… |
… |
void RecordingSelector::getRecordingList(void) |
428 | 428 | // ignore live tv and deleted recordings |
429 | 429 | if (p->recgroup == "LiveTV" || p->recgroup == "Deleted") |
430 | 430 | { |
431 | | recordingList->erase(i); |
| 431 | i = recordingList->erase(i); |
432 | 432 | i--; |
433 | 433 | continue; |
434 | 434 | } |
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) |
847 | 847 | img_convert(&retbuf, PIX_FMT_RGBA32, |
848 | 848 | (AVPicture*) m_frame, m_codecCtx->pix_fmt, m_frameWidth, m_frameHeight); |
849 | 849 | |
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); |
852 | 852 | |
853 | 853 | if (!img.save(m_frameFile.ascii(), "JPEG")) |
854 | 854 | { |
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 |
752 | 752 | QString title = "", filename = ""; |
753 | 753 | bool doDelete = false; |
754 | 754 | QString dbVersion = gContext->GetSetting("DBSchemaVer", ""); |
755 | | int intID, categoryID = 0; |
| 755 | int intID = 0, categoryID = 0; |
756 | 756 | QString coverFile = ""; |
757 | 757 | |
758 | 758 | title = itemNode.attribute("title"); |
… |
… |
int grabThumbnail(QString inFile, QString thumbList, QString outFile, int frameC |
1842 | 1842 | img_convert(&retbuf, PIX_FMT_RGBA32, |
1843 | 1843 | (AVPicture*) frame, codecCtx->pix_fmt, width, height); |
1844 | 1844 | |
1845 | | QImage img(outputbuf, width, height, 32, NULL, |
1846 | | 65536 * 65536, QImage::LittleEndian); |
| 1845 | QImage img(outputbuf, width, height, |
| 1846 | QImage::Format_RGB32); |
1847 | 1847 | |
1848 | 1848 | if (!img.save(filename.ascii(), saveFormat)) |
1849 | 1849 | { |
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, |
367 | 367 | /* seek to palette */ |
368 | 368 | xfseek0(fh, pgc + 0xa4); |
369 | 369 | xxfread(fh, buf, 16 * 4); |
| 370 | fclose(fh); |
370 | 371 | for (i = 0; i < 16; i++) |
371 | 372 | { |
372 | 373 | eu8 * p = buf + i * 4 + 1; |
… |
… |
int sup2dast(const char *supfile, const char *ifofile ,int delay_ms) |
863 | 864 | bool createpics; |
864 | 865 | FILE * fh; |
865 | 866 | |
| 867 | memset(yuvpalette, 0, sizeof(yuvpalette)); |
| 868 | memset(rgbpalette, 0, sizeof(rgbpalette)); |
| 869 | |
866 | 870 | write(1, "\n", 1); |
867 | 871 | if (sizeof (char) != 1 || sizeof (int) < 2) /* very unlikely */ |
868 | 872 | exc_throw(MiscError, "Incompatible variable sizes."); |