Fix pldm crashes
This commit attempts to fix three PLDM crashes
1. Capturing handler using a reference in dbus match handling
lambda function.
dbus matches are aync,so by the time we get a dbus match we would
have exited the function in which the dbus match lambda is defined
so the handler would be nullptr , and dereferencing them would lead
to a segmentation fault.
2. We cannot be deleting elements of a container while iterating over
the same container.
Reference : https://en.wikipedia.org/wiki/Erase%E2%80%93remove_idiom
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I54cb03ccf61c4fa50fbf7fb34f7b014d0247ea7b
diff --git a/oem/ibm/libpldmresponder/file_io.hpp b/oem/ibm/libpldmresponder/file_io.hpp
index 10c6d47..ee8074d 100644
--- a/oem/ibm/libpldmresponder/file_io.hpp
+++ b/oem/ibm/libpldmresponder/file_io.hpp
@@ -234,7 +234,7 @@
sdbusplus::bus::match::rules::interfacesAdded() +
sdbusplus::bus::match::rules::argNpath(0, dumpObjPath),
[this, hostSockFd, hostEid, dbusImplReqester,
- &handler](sdbusplus::message::message& msg) {
+ handler](sdbusplus::message::message& msg) {
std::map<
std::string,
std::map<std::string, std::variant<std::string, uint32_t>>>
@@ -277,7 +277,7 @@
sdbusplus::bus::match::rules::interfacesAdded() +
sdbusplus::bus::match::rules::argNpath(0, certObjPath),
[this, hostSockFd, hostEid, dbusImplReqester,
- &handler](sdbusplus::message::message& msg) {
+ handler](sdbusplus::message::message& msg) {
std::map<
std::string,
std::map<std::string, std::variant<std::string, uint32_t>>>