Skip to content

Commit

Permalink
[devicelock] Fix crash when the setState dbus function is called and …
Browse files Browse the repository at this point in the history
…locking is disabled. Fixes JB#37616

The QDBusContext of the adaptor wasn't populated when a method was
called and QDBusContext doesn't guard internal uses of its possibly null
d_ptr resulting in a crash when attempting to send an error reply.

Remove the QDBusContext from MceDeviceLockAdaptor and use the instance
from MceDeviceLock instead.
  • Loading branch information
adenexter committed Feb 8, 2017
1 parent 23f2293 commit b862fda
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/nemo-devicelock/host/mcedevicelock.cpp
Expand Up @@ -224,7 +224,7 @@ bool MceDeviceLock::getRequiredLockState()
bool MceDeviceLock::needLockTimer()
{
/* Must be currently unlocked */
if (!m_locked)
if (m_locked)
return false;

/* Must not be disabled or in lock-immediate mode */
Expand Down Expand Up @@ -344,9 +344,9 @@ void MceDeviceLockAdaptor::setState(int state)
{
if (state != DeviceLock::Locked) {
// Unauthenticated unlocking is not accepted.
sendErrorReply(QDBusError::AccessDenied);
m_deviceLock->sendErrorReply(QDBusError::AccessDenied);
} else if (m_deviceLock->automaticLocking() == -1) {
sendErrorReply(QDBusError::AccessDenied, QStringLiteral("Device lock not in use"));
m_deviceLock->sendErrorReply(QDBusError::AccessDenied, QStringLiteral("Device lock not in use"));
} else {
m_deviceLock->setLocked(true);
}
Expand Down
2 changes: 1 addition & 1 deletion src/nemo-devicelock/host/mcedevicelock.h
Expand Up @@ -47,7 +47,7 @@ namespace NemoDeviceLock

class MceDeviceLock;

class MceDeviceLockAdaptor : public QDBusAbstractAdaptor, protected QDBusContext
class MceDeviceLockAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.nemomobile.lipstick.devicelock")
Expand Down

0 comments on commit b862fda

Please sign in to comment.