pldmd: Account for pldm_entity_association_tree_init() returning NULL
As with handling pldm_pdr_init() failures, throw a std::runtime_error()
for pldm_entity_association_tree_init() failures. Throwing is an
improvement thanks to unwinding, by comparison to the immediate
termination invoked by assert().
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I3d5d6bed5afa76503f16ec9d1842cf4fd09e9ae7
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 37121b9..4df9f02 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -219,10 +219,20 @@
decltype(&pldm_entity_association_tree_destroy)>
entityTree(pldm_entity_association_tree_init(),
pldm_entity_association_tree_destroy);
+ if (!entityTree)
+ {
+ throw std::runtime_error(
+ "Failed to instantiate general PDR entity association tree");
+ }
std::unique_ptr<pldm_entity_association_tree,
decltype(&pldm_entity_association_tree_destroy)>
bmcEntityTree(pldm_entity_association_tree_init(),
pldm_entity_association_tree_destroy);
+ if (!bmcEntityTree)
+ {
+ throw std::runtime_error(
+ "Failed to instantiate BMC PDR entity association tree");
+ }
std::shared_ptr<HostPDRHandler> hostPDRHandler;
std::unique_ptr<pldm::host_effecters::HostEffecterParser>
hostEffecterParser;