Skip to content

Commit

Permalink
Fix possible crash during write to disk error
Browse files Browse the repository at this point in the history
  • Loading branch information
LostDragonist committed Aug 21, 2018
1 parent ef771fd commit 258bddb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/downloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,11 +1845,12 @@ void DownloadManager::writeData(DownloadInfo *info)
if (info != nullptr) {
qint64 ret = info->m_Output.write(info->m_Reply->readAll());
if (ret < info->m_Reply->size()) {
QString fileName = info->m_FileName; // m_FileName may be destroyed after setState
setState(info, DownloadState::STATE_CANCELED);
qCritical(QString("Unable to write download \"%2\" to drive (return %1)").arg(ret).arg(info->m_FileName).toLocal8Bit());
reportError(tr("Unable to write download to drive (return %1).\n"
"Check the drive's available storage.\n\n"
"Canceling download \"%2\"...").arg(ret).arg(info->m_FileName));
"Canceling download \"%2\"...").arg(ret).arg(fileName));
}
}
}

0 comments on commit 258bddb

Please sign in to comment.