Fix account service
Session might not be initialized, and might be nullptr.
This line was accessing the session BEFORE the nullptr check. Move it
to after. Found using static analysis.
Change-Id: I966c642aee7c76a29c7d0d57d3b78f5f7bef7d62
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 47fb58d..dc393ae 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -1899,14 +1899,14 @@
std::optional<bool> locked;
std::optional<std::vector<std::string>> accountTypes;
- bool userSelf = (username == req.session->username);
-
if (req.session == nullptr)
{
messages::internalError(asyncResp->res);
return;
}
+ bool userSelf = (username == req.session->username);
+
Privileges effectiveUserPrivileges =
redfish::getUserPrivileges(*req.session);
Privileges configureUsers = {"ConfigureUsers"};