diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-04-15 20:29:00 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2019-04-15 20:29:00 +0900 |
commit | 533f837086d3522c54f0622d3f27e0a5d1347b24 (patch) | |
tree | 52495f84acffcfd21494a1f2911b852f73d1a451 /lib/jobs/basejob.cpp | |
parent | 613e3754dccc56334c6a132381c230781619f264 (diff) | |
download | libquotient-533f837086d3522c54f0622d3f27e0a5d1347b24.tar.gz libquotient-533f837086d3522c54f0622d3f27e0a5d1347b24.zip |
BaseJob: fix a possible crash upon logout
See https://github.com/QMatrixClient/Quaternion/issues/566 for details.
Diffstat (limited to 'lib/jobs/basejob.cpp')
-rw-r--r-- | lib/jobs/basejob.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/jobs/basejob.cpp b/lib/jobs/basejob.cpp index f521cc4b..a79d0e03 100644 --- a/lib/jobs/basejob.cpp +++ b/lib/jobs/basejob.cpp @@ -600,10 +600,25 @@ QUrl BaseJob::errorUrl() const void BaseJob::setStatus(Status s) { + // The crash that led to this code has been reported in + // https://github.com/QMatrixClient/Quaternion/issues/566 - basically, + // when cleaning up childrent of a deleted Connection, there's a chance + // of pending jobs being abandoned, calling setStatus(Abandoned). + // There's nothing wrong with this; however, the safety check for + // cleartext access tokens below uses d->connection - which is a dangling + // pointer. + // To alleviate that, a stricter condition is applied, that for Abandoned + // and to-be-Abandoned jobs the status message will be disregarded entirely. + // For 0.6 we might rectify the situation by making d->connection + // a QPointer<> (and derive ConnectionData from QObject, respectively). + if (d->status.code == Abandoned || s.code == Abandoned) + s.message.clear(); + if (d->status == s) return; - if (d->connection && !d->connection->accessToken().isEmpty()) + if (!s.message.isEmpty() + && d->connection && !d->connection->accessToken().isEmpty()) s.message.replace(d->connection->accessToken(), "(REDACTED)"); if (!s.good()) qCWarning(d->logCat) << this << "status" << s; |