Fix core dump in callPIM
If the system config JSON does not start with the PIM base path
‘/xyz/openbmc_project/inventory’, the callPIM API fails while
publishing inventory on D-Bus. This happens because the ObjectMap
entry is removed before checking whether the object path starts with
the PIM base path, and the entry is not reinserted if it does not.
This leaves the object invalid for the next iteration, resulting in a
core dump. Changes are made to handle this issue properly.
This commit also updates inventory object path with
‘/xyz/openbmc_project/inventory’ as a base path in default system
config JSON.
Change-Id: Ia9c4b0b96c9d0302787f07e5afbf896c9dfc62f9
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd-manager/include/utility/dbus_utility.hpp b/vpd-manager/include/utility/dbus_utility.hpp
index df57cd1..c155d0c 100644
--- a/vpd-manager/include/utility/dbus_utility.hpp
+++ b/vpd-manager/include/utility/dbus_utility.hpp
@@ -267,11 +267,10 @@
{
for (const auto& l_objectKeyValue : objectMap)
{
- auto l_nodeHandle = objectMap.extract(l_objectKeyValue.first);
-
- if (l_nodeHandle.key().str.find(constants::pimPath, 0) !=
+ if (l_objectKeyValue.first.str.find(constants::pimPath, 0) !=
std::string::npos)
{
+ auto l_nodeHandle = objectMap.extract(l_objectKeyValue.first);
l_nodeHandle.key() = l_nodeHandle.key().str.replace(
0, std::strlen(constants::pimPath), "");
objectMap.insert(std::move(l_nodeHandle));