aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/Input/archive/archiveinputdevice.cpp14
-rw-r--r--src/plugins/Input/archive/decoderarchivefactory.cpp8
2 files changed, 21 insertions, 1 deletions
diff --git a/src/plugins/Input/archive/archiveinputdevice.cpp b/src/plugins/Input/archive/archiveinputdevice.cpp
index 22cfa2372..5b11a2938 100644
--- a/src/plugins/Input/archive/archiveinputdevice.cpp
+++ b/src/plugins/Input/archive/archiveinputdevice.cpp
@@ -80,6 +80,9 @@ ArchiveInputDevice::~ArchiveInputDevice()
bool ArchiveInputDevice::seek(qint64 pos)
{
+ if(!isOpen())
+ return false;
+
QIODevice::seek(pos);
if(pos > m_buffer.size())
@@ -99,10 +102,11 @@ bool ArchiveInputDevice::seek(qint64 pos)
else if(r < 0)
{
qWarning("ArchiveInputDevice: seeking failed; libarchive error: %s", archive_error_string(m_archive));
+ setErrorString(QString::fromLocal8Bit(archive_error_string(m_archive)));
+ close();
}
return false;
}
-
}
return m_buffer.seek(pos);
@@ -115,6 +119,9 @@ qint64 ArchiveInputDevice::size() const
qint64 ArchiveInputDevice::readData(char *data, qint64 maxSize)
{
+ if(!isOpen())
+ return -1;
+
if(m_buffer.pos() + maxSize > m_buffer.size())
{
qint64 l = m_buffer.pos() + maxSize - m_buffer.size();
@@ -123,7 +130,12 @@ qint64 ArchiveInputDevice::readData(char *data, qint64 maxSize)
if(r > 0)
m_buffer.buffer().append(tmp, r);
else if(r < 0)
+ {
qWarning("ArchiveInputDevice: reading failed; libarchive error: %s", archive_error_string(m_archive));
+ setErrorString(QString::fromLocal8Bit(archive_error_string(m_archive)));
+ close();
+ return -1;
+ }
}
return m_buffer.read(data, maxSize);
}
diff --git a/src/plugins/Input/archive/decoderarchivefactory.cpp b/src/plugins/Input/archive/decoderarchivefactory.cpp
index 3b83616c2..119e30d83 100644
--- a/src/plugins/Input/archive/decoderarchivefactory.cpp
+++ b/src/plugins/Input/archive/decoderarchivefactory.cpp
@@ -112,6 +112,14 @@ QList<TrackInfo *> DecoderArchiveFactory::createPlayList(const QString &path, Tr
ArchiveInputDevice dev(a, entry, nullptr);
ArchiveTagReader reader(&dev, list.last()->path());
+ if(!dev.isOpen())
+ {
+ qDeleteAll(list);
+ list.clear();
+ archive_read_free(a);
+ return list;
+ }
+
if(parts & TrackInfo::MetaData)
list.last()->setValues(reader.metaData());