pldmd: Account for pldm_pdr_init() returning NULL

Historically, libpldm's pldm_pdr_init() has internall used assert() to
enforce that the returned value is not NULL. Efforts are underway to
remove this reliance on assert() in libpldm to ensure consumers aren't
ungracefully terminated.

This change chooses to return an appropriate error to the
caller of pldmd's internal APIs where possible. However, in a number of
circumstances there was either not a sensible value that could be
returned, or it was not possible to return a value without further
refactoring. In these circumstances we choose to throw
`std::runtime_error`, which will at least do what it can to unwind.
While it may feel like it falls short of proper error handling, the
reality is the calling code is already structured such that it pretends
allocation failures never occur. The switch to throwing a runtime error
makes a strict improvement over the immediate termination implemented by
assert().

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: Ibb6bc3abf62e32f05ac079453853873298db6c4f
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index fed0421..8d2c74e 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -304,6 +304,11 @@
 
         std::unique_ptr<pldm_pdr, decltype(&pldm_pdr_destroy)>
             stateEffecterPdrRepo(pldm_pdr_init(), pldm_pdr_destroy);
+        if (!stateEffecterPdrRepo)
+        {
+            throw std::runtime_error(
+                "Failed to instantiate state effecter PDR repository");
+        }
         pldm::responder::pdr_utils::Repo stateEffecterPDRs(
             stateEffecterPdrRepo.get());
         getRepoByType(pdrRepo, stateEffecterPDRs, PLDM_STATE_EFFECTER_PDR);