From b45c8b7ea4dd6d3efa63c019f88de2045d575330 Mon Sep 17 00:00:00 2001 From: Max Kolhagen Date: Sun, 22 Apr 2018 17:41:46 +0200 Subject: [PATCH] Fix QSharedPointer initialization --- src/touchid/TouchID.h | 4 ++-- src/touchid/TouchID.mm | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/touchid/TouchID.h b/src/touchid/TouchID.h index 9135448eeb..fa858f7853 100644 --- a/src/touchid/TouchID.h +++ b/src/touchid/TouchID.h @@ -27,8 +27,8 @@ class TouchID // TouchID(TouchID const&); // Don't Implement // void operator=(TouchID const&); // Don't implement - QSharedPointer m_encryptedMasterKey = NULL; - QSharedPointer m_databasePath = NULL; + QSharedPointer m_encryptedMasterKey; + QSharedPointer m_databasePath; int m_available = -1; public: diff --git a/src/touchid/TouchID.mm b/src/touchid/TouchID.mm index faa2d2cab4..fd75affc04 100644 --- a/src/touchid/TouchID.mm +++ b/src/touchid/TouchID.mm @@ -20,7 +20,7 @@ inline void debug(const char* message, ...) /* Generates a random AES 256bit key and uses it to encrypt the PasswordKey that protects the database. The encrypted PasswordKey is kept in memory while the AES key is stored in the macOS KeyChain protected by TouchID. */ bool TouchID::storeKey(const QByteArray& passwordKey, const QString& databasePath) { - if (this->m_databasePath != NULL && *(this->m_databasePath) == databasePath) { + if (!this->m_databasePath.isNull() && *(this->m_databasePath) == databasePath) { // already stored key for this database debug("TouchID::storeKey - Already stored key for this database"); return true; @@ -98,8 +98,8 @@ inline void debug(const char* message, ...) if (status != errSecSuccess) { debug("TouchID::storeKey - Not successful, resetting TouchID"); - this->m_encryptedMasterKey = NULL; - this->m_databasePath = NULL; + this->m_encryptedMasterKey.clear(); + this->m_databasePath.clear(); return false; } @@ -110,8 +110,8 @@ inline void debug(const char* message, ...) QSharedPointer TouchID::getKey(const QString& databasePath) const { // checks if encrypted PasswordKey is available and is stored for the given database - if (this->m_encryptedMasterKey == NULL || - this->m_databasePath == NULL || + if (this->m_encryptedMasterKey.isNull() || + this->m_databasePath.isNull() || *(this->m_databasePath) != databasePath) { debug("TouchID::getKey - No stored key found"); return NULL; @@ -220,6 +220,6 @@ inline void debug(const char* message, ...) /* Resets the inner state */ void TouchID::reset() { - this->m_encryptedMasterKey = NULL; - this->m_databasePath = NULL; + this->m_encryptedMasterKey.clear(); + this->m_databasePath.clear(); }