Skip to content

Commit

Permalink
Merge pull request #5637 from nextcloud/bugfix/fix-crash-ptr-deref
Browse files Browse the repository at this point in the history
Edit locally. Fix crash on _chekTokenJob pointer deref.
  • Loading branch information
allexzander authored May 4, 2023
2 parents 5bde789 + cda8da3 commit cc69701
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/gui/editlocallyjob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ void EditLocallyJob::startTokenRemoteCheck()
const auto encodedToken = QString::fromUtf8(QUrl::toPercentEncoding(_token)); // Sanitise the token
const auto encodedRelPath = QUrl::toPercentEncoding(_relPath); // Sanitise the relPath

_checkTokenJob.reset(new SimpleApiJob(_accountState->account(),
QStringLiteral("/ocs/v2.php/apps/files/api/v1/openlocaleditor/%1").arg(encodedToken)));
const auto checkTokenJob = new SimpleApiJob(_accountState->account(),
QStringLiteral("/ocs/v2.php/apps/files/api/v1/openlocaleditor/%1").arg(encodedToken));

QUrlQuery params;
params.addQueryItem(QStringLiteral("path"), prefixSlashToPath(encodedRelPath));
_checkTokenJob->addQueryParams(params);
_checkTokenJob->setVerb(SimpleApiJob::Verb::Post);
connect(_checkTokenJob.get(), &SimpleApiJob::resultReceived, this, &EditLocallyJob::remoteTokenCheckResultReceived);
checkTokenJob->addQueryParams(params);
checkTokenJob->setVerb(SimpleApiJob::Verb::Post);
connect(checkTokenJob, &SimpleApiJob::resultReceived, this, &EditLocallyJob::remoteTokenCheckResultReceived);

_checkTokenJob->start();
checkTokenJob->start();
}

void EditLocallyJob::remoteTokenCheckResultReceived(const int statusCode)
Expand Down
1 change: 0 additions & 1 deletion src/gui/editlocallyjob.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ private slots:
QString _localFilePath;
QString _folderRelativePath;
Folder *_folderForFile = nullptr;
std::unique_ptr<SimpleApiJob> _checkTokenJob;
QMetaObject::Connection _syncTerminatedConnection = {};
QVector<QMetaObject::Connection> _folderConnections;
};
Expand Down

0 comments on commit cc69701

Please sign in to comment.