aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/archive/archiveinputdevice.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-05-06 19:28:35 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2019-05-06 19:28:35 +0000
commit8f97d76080b9617fc67d01f2bc8de36a5b0a1175 (patch)
treeb0b9287109dd54a3b3dc709c72c0dc6a69d03d29 /src/plugins/Input/archive/archiveinputdevice.cpp
parent23585bba435a25c59433f084e9ba2f5a212d2c21 (diff)
downloadqmmp-8f97d76080b9617fc67d01f2bc8de36a5b0a1175.tar.gz
qmmp-8f97d76080b9617fc67d01f2bc8de36a5b0a1175.tar.bz2
qmmp-8f97d76080b9617fc67d01f2bc8de36a5b0a1175.zip
archive: fixed crash on some corrupted archives (#998)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8861 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/archive/archiveinputdevice.cpp')
-rw-r--r--src/plugins/Input/archive/archiveinputdevice.cpp14
1 files changed, 13 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);
}