Add nullptr check
Change-Id: If511f1210cca7bd1da3a8c5152688487d3036e2f
Signed-off-by: Ed Tanous <ed@tanous.net>
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index 9392916..223522b 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -712,7 +712,11 @@
{
const std::string* strProperty =
std::get_if<std::string>(&property.second);
-
+ if (strProperty == nullptr)
+ {
+ BMCWEB_LOG_ERROR("Function wasn't a string?");
+ continue;
+ }
if (property.first == functionName + "DeviceId")
{
resp.jsonValue["DeviceId"] = *strProperty;
@@ -799,11 +803,12 @@
systemName);
return;
}
+ std::string_view pcieFunctionIdView = pcieFunctionIdStr;
uint64_t pcieFunctionId = 0;
std::from_chars_result result = std::from_chars(
- &*pcieFunctionIdStr.begin(), &*pcieFunctionIdStr.end(), pcieFunctionId);
- if (result.ec != std::errc{} || result.ptr != &*pcieFunctionIdStr.end())
+ pcieFunctionIdView.begin(), pcieFunctionIdView.end(), pcieFunctionId);
+ if (result.ec != std::errc{} || result.ptr != pcieFunctionIdView.end())
{
messages::resourceNotFound(asyncResp->res, "PCIeFunction",
pcieFunctionIdStr);