mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Abort: Fix crash with early aborts
_chunkCount could be 0, leading to a floating point exception I also added initializers for several uninitialized integers in the upload jobs.
This commit is contained in:
parent
e2711224ed
commit
b2a8ffc577
@ -301,15 +301,15 @@ private:
|
||||
* In the non-resuming case it is 0.
|
||||
* If we are resuming, this is the first chunk we need to send
|
||||
*/
|
||||
int _startChunk;
|
||||
int _startChunk = 0;
|
||||
/**
|
||||
* This is the next chunk that we need to send. Starting from 0 even if _startChunk != 0
|
||||
* (In other words, _startChunk + _currentChunk is really the number of the chunk we need to send next)
|
||||
* (In other words, _currentChunk is the number of the chunk that we already sent or started sending)
|
||||
*/
|
||||
int _currentChunk;
|
||||
int _chunkCount; /// Total number of chunks for this file
|
||||
int _transferId; /// transfer id (part of the url)
|
||||
int _currentChunk = 0;
|
||||
int _chunkCount = 0; /// Total number of chunks for this file
|
||||
int _transferId = 0; /// transfer id (part of the url)
|
||||
|
||||
quint64 chunkSize() const {
|
||||
// Old chunking does not use dynamic chunking algorithm, and does not adjusts the chunk size respectively,
|
||||
@ -342,11 +342,11 @@ class PropagateUploadFileNG : public PropagateUploadFileCommon
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
quint64 _sent; /// amount of data (bytes) that was already sent
|
||||
uint _transferId; /// transfer id (part of the url)
|
||||
int _currentChunk; /// Id of the next chunk that will be sent
|
||||
quint64 _currentChunkSize; /// current chunk size
|
||||
bool _removeJobError; /// If not null, there was an error removing the job
|
||||
quint64 _sent = 0; /// amount of data (bytes) that was already sent
|
||||
uint _transferId = 0; /// transfer id (part of the url)
|
||||
int _currentChunk = 0; /// Id of the next chunk that will be sent
|
||||
quint64 _currentChunkSize = 0; /// current chunk size
|
||||
bool _removeJobError = false; /// If not null, there was an error removing the job
|
||||
|
||||
// Map chunk number with its size from the PROPFIND on resume.
|
||||
// (Only used from slotPropfindIterate/slotPropfindFinished because the LsColJob use signals to report data.)
|
||||
@ -366,7 +366,6 @@ private:
|
||||
public:
|
||||
PropagateUploadFileNG(OwncloudPropagator *propagator, const SyncFileItemPtr &item)
|
||||
: PropagateUploadFileCommon(propagator, item)
|
||||
, _currentChunkSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -363,8 +363,10 @@ void PropagateUploadFileV1::abort(PropagatorJob::AbortType abortType)
|
||||
// dont abort final PUT which uploaded its data,
|
||||
// since this might result in conflicts
|
||||
if (PUTFileJob *putJob = qobject_cast<PUTFileJob *>(job)){
|
||||
if (abortType == AbortType::Asynchronous && (((_currentChunk + _startChunk) % _chunkCount) == 0)
|
||||
&& putJob->device()->atEnd()) {
|
||||
if (abortType == AbortType::Asynchronous
|
||||
&& _chunkCount > 0
|
||||
&& (((_currentChunk + _startChunk) % _chunkCount) == 0)
|
||||
&& putJob->device()->atEnd()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user