LogService: Fix potential null pointer dereference

Querying CollectDiagnosticData Action results in a crash if there is
not an active user session.  Fixes the null pointer dereferencing
introduced by https://gerrit.openbmc.org/c/openbmc/bmcweb/+/58688.

Tested:
Queried the Action URI and received a response instead of bmcweb
crashing
curl -X POST -H 'Content-Type: application/json' \
localhost/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData/ \
-d '{"DiagnosticDataType": "Manager"}'
{
  "@odata.id": "/redfish/v1/TaskService/Tasks/0",
  "@odata.type": "#Task.v1_4_3.Task",
  "Id": "0",
  "TaskState": "Running",
  "TaskStatus": "OK"
}

Signed-off-by: Carson Labrado <clabrado@google.com>
Change-Id: Ic46ece84598613e4bbe51f4188a623ba857c18a0
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 6dcfd78..f549397 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -946,12 +946,15 @@
     std::vector<std::pair<std::string, std::variant<std::string, uint64_t>>>
         createDumpParamVec;
 
-    createDumpParamVec.emplace_back(
-        "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorId",
-        req.session->clientIp);
-    createDumpParamVec.emplace_back(
-        "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorType",
-        "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Client");
+    if (req.session != nullptr)
+    {
+        createDumpParamVec.emplace_back(
+            "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorId",
+            req.session->clientIp);
+        createDumpParamVec.emplace_back(
+            "xyz.openbmc_project.Dump.Create.CreateParameters.OriginatorType",
+            "xyz.openbmc_project.Common.OriginatedBy.OriginatorTypes.Client");
+    }
 
     crow::connections::systemBus->async_method_call(
         [asyncResp, payload(task::Payload(req)),