Fix possible property access on `null` in `SessionHandler::applyPendingUserChange()`
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 17 May 2021 10:01:08 +0000 (12:01 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 17 May 2021 10:01:08 +0000 (12:01 +0200)
wcfsetup/install/files/lib/system/session/SessionHandler.class.php

index 3792bc731312df0aa60f5e34942f7e7758e93ed8..bdc00eb17bd4196b7bde2ede6d0e034c66bcc846 100644 (file)
@@ -917,14 +917,14 @@ final class SessionHandler extends SingletonFactory
         $user = $this->getPendingUserChange();
         $this->clearPendingUserChange();
 
-        if ($user->userID !== $expectedUser->userID) {
-            throw new \RuntimeException('Mismatching expectedUser.');
-        }
-
         if (!$user) {
             throw new \BadMethodCallException('No pending user change.');
         }
 
+        if ($user->userID !== $expectedUser->userID) {
+            throw new \RuntimeException('Mismatching expectedUser.');
+        }
+
         $this->changeUser($user);
     }