mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-31 03:50:20 -07:00
Fix crash when a fastresume file is empty (closes #52)
This commit is contained in:
parent
879f8f080d
commit
d2a6887248
1 changed files with 6 additions and 1 deletions
|
@ -869,11 +869,16 @@ bool QBtSession::loadFastResumeData(const QString &hash, std::vector<char> &buf)
|
||||||
const QString fastresume_path = QDir(fsutils::BTBackupLocation()).absoluteFilePath(hash+QString(".fastresume"));
|
const QString fastresume_path = QDir(fsutils::BTBackupLocation()).absoluteFilePath(hash+QString(".fastresume"));
|
||||||
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
|
qDebug("Trying to load fastresume data: %s", qPrintable(fastresume_path));
|
||||||
QFile fastresume_file(fastresume_path);
|
QFile fastresume_file(fastresume_path);
|
||||||
if (!fastresume_file.open(QIODevice::ReadOnly)) return false;
|
if (fastresume_file.size() <= 0)
|
||||||
|
return false;
|
||||||
|
if (!fastresume_file.open(QIODevice::ReadOnly))
|
||||||
|
return false;
|
||||||
const QByteArray content = fastresume_file.readAll();
|
const QByteArray content = fastresume_file.readAll();
|
||||||
const int content_size = content.size();
|
const int content_size = content.size();
|
||||||
|
Q_ASSERT(content_size > 0);
|
||||||
buf.resize(content_size);
|
buf.resize(content_size);
|
||||||
memcpy(&buf[0], content.data(), content_size);
|
memcpy(&buf[0], content.data(), content_size);
|
||||||
|
fastresume_file.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue