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-24 10:40:41 +0900 |
commit | a6df4183d6da324f2c2329f21d732071b3337cb8 (patch) | |
tree | 0f7216868aef113c0b69514f7264d61755200fcd /lib | |
parent | af55d9a0f23ed48c7dcec26efe6b01fb44a8c4fc (diff) | |
download | libquotient-a6df4183d6da324f2c2329f21d732071b3337cb8.tar.gz libquotient-a6df4183d6da324f2c2329f21d732071b3337cb8.zip |
BaseJob: fix a possible crash upon logout
See https://github.com/QMatrixClient/Quaternion/issues/566 for details.
Diffstat (limited to 'lib')
-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; |