Skip to content

Commit

Permalink
Fix QSharedPointer initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
k6nmx committed Apr 22, 2018
1 parent ff1e748 commit b45c8b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/touchid/TouchID.h
Expand Up @@ -27,8 +27,8 @@ class TouchID
// TouchID(TouchID const&); // Don't Implement
// void operator=(TouchID const&); // Don't implement

QSharedPointer<QByteArray> m_encryptedMasterKey = NULL;
QSharedPointer<QString> m_databasePath = NULL;
QSharedPointer<QByteArray> m_encryptedMasterKey;
QSharedPointer<QString> m_databasePath;
int m_available = -1;

public:
Expand Down
14 changes: 7 additions & 7 deletions src/touchid/TouchID.mm
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -110,8 +110,8 @@ inline void debug(const char* message, ...)
QSharedPointer<QByteArray> 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;
Expand Down Expand Up @@ -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();
}

0 comments on commit b45c8b7

Please sign in to comment.