Fix segfault caused by accessing non existing key in busmap
Tested:
- Succesfully boot OpenBMC with error that key does not exist in
busmap.
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
Change-Id: I79736a786f9a88886ee8c54f7c6bf6e32d855769
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index d593c30..0ef0269 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -1348,8 +1348,12 @@
objServer.remove_interface(busIface.second);
}
}
- auto& devicemap = busmap[busNum];
- for (auto& device : *devicemap)
+ auto found = busmap.find(busNum);
+ if (found == busmap.end() || found->second == nullptr)
+ {
+ return;
+ }
+ for (auto& device : *(found->second))
{
AddFruObjectToDbus(device.second, dbusInterfaceMap,
static_cast<uint32_t>(busNum), device.first);