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:
parent
e54f7f2d8a
commit
d9b95dac5f
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue