AuthManager

- Fixed null pointer dereference error in `getUser(string)` which would occur when a user entry was not found in the hashmap
This commit is contained in:
Tristan B. Velloza Kildaire 2023-11-22 21:54:38 +02:00
parent e54f7f2d8a
commit d9b95dac5f
1 changed files with 16 additions and 7 deletions

View File

@ -252,17 +252,26 @@ public class AuthManager
// NOTE: Don't try de-allocate it, smart ass
public User* getUser(string username)
{
User* foundUser;
// Lock
this.usersLock.lock();
foundUser = *(username in this.users);
// On exit
scope(exit)
{
// Unlock
this.usersLock.unlock();
}
// Unlock
this.usersLock.unlock();
return foundUser;
// Check if such a user exists
User** potentialUserPtrPtr = username in this.users;
if(potentialUserPtrPtr == null)
{
return null;
}
else
{
return *potentialUserPtrPtr;
}
}
private void addUser(string username)